Anil Kumar
BAN USER
- 0of 0 votes
AnswerGiven two arrays. One is for tasks (Processes) and each element depicts the amount of cores required to run the task. 2nd array is an array of CPU where each element depicts the no of cores in it.We have to tell how many maximum number of tasks can be allocated. Example: Task: [3, 5, 7], Cores: [1, 3, 5] . Here only task 0 and 1 can be allocated to CPU 1 and 2 . So, answer=2.
- Anil Kumar in India| Report Duplicate | Flag | PURGE
Amazon SDE1
RepHi, I’m Jamie from the Portsmouth USA and I am working as an account manager. I work for a ...
RepHello friends my name Neha Nanda from India Chandigarh city. Doing work in SEO line in Softsys company.
RepMelodyTHeckler, abc at ABC TECH SUPPORT
Earned praised for my work lecturing about get love back by vashikaran. Spent childhood promoting art posters in Jacksonville, FL ...
Repannasteven1246, Analyst at Accenture
Creative, highly visual fashion professional who can brilliantly mix and match the technical expertise and intuition like fabric and color ...
Repsherrymrex, Computer Scientist at CGI-AMS
I am Sherry from West Palm Beach USA, I started my journey in 2016 as a yoga teacher. I like ...
RepMy name Madhu Nanda from Himachal pardesh. I am a writter in English lectractrue.
RepPatriciaNRowe, Consultant at ADP
Hi i am a Freelance Writer and Social Media Manager who helps finance professionals and Fin-tech startups build an audience ...
Repcrystalblibby, Analyst at Achieve Internet
By professional i am teacher. Successfully supervised and assisted students, grade artwork, encouraged creativity and new technique.Familiar with art ...
RepSpent 2001-2004 selling UFOs for the government. Have some experience with Internet Marketing Services New York. Set new standards for ...
Repannarrathjen, Employee at 247quickbookshelp
Hello, My name is Anna and I am a medical records technician with 2 years of experience and achievements. I ...
Repedenwraye, Photographic spotter at Enrich Garden Services
I'm more of a Photographic spotter than an expert at creating beautiful, functional and personalised products for teachers, mentors ...
RepI am an energetic sales professional with a track record of consistently increasing sales revenue in a competitive market. Contract ...
#include <stdio.h>
- Anil Kumar March 07, 2014#include <string.h>
struct tree *newnode(int data);
void push(int **data);
struct list
{
int data;
struct list *next;
}*top, *currentlevel=NULL,*nextlevel=NULL;
struct tree
{
int data;
struct tree *left;
struct tree *right;
};
main()
{
struct tree *tree1=newnode(1);
tree1->left=newnode(2);
tree1->right=newnode(3);
tree1->left->left=newnode(4);
tree1->left->right=newnode(5);
tree1->right->left=newnode(6);
tree1->right->right=newnode(7);
tree1->left->left->left=newnode(8);
tree1->left->left->right=newnode(9);
tree1->left->right->left=newnode(10);
tree1->left->right->right=newnode(11);
tree1->right->left->left=newnode(12);
tree1->right->left->right=newnode(13);
tree1->right->right->left=newnode(14);
tree1->right->right->right=newnode(15);
zigzag(tree1);
}
int zigzag(struct list *tree1)
{
int lefttoright=1;
push(tree1);
while(!isEmpty())
{
struct tree *tree3=pop();
printf(" %d",tree3->data);
if(lefttoright)
{
if(tree3->left!=0)
{
push1(tree3->left);
}
if(tree3->right!=0)
{
push1(tree3->right);
}
}
else
{
if(tree3->right!=0)
{
push1(tree3->right);
}
if(tree3->left!=0)
{
push1(tree3->left);
}
}
while(isEmpty())
{
lefttoright=1-lefttoright;
swap();
}
}
}
void swap()
{
currentlevel=nextlevel;
nextlevel=NULL;
}
int pop()
{
struct list *ptr;
ptr=currentlevel->data;
if(currentlevel==NULL)
{
printf(" overflow ");
}
currentlevel=currentlevel->next;
return ptr;
}
int isEmpty()
{
if(currentlevel==NULL)
{
return 1;
}
else
{
return 0;
}
}
struct tree *newnode(int data)
{
struct tree *tree3;
tree3=(struct tree *)malloc(sizeof(struct tree));
tree3->data=data;
tree3->left=NULL;
tree3->right=NULL;
return tree3;
}
void push(int **data)
{
struct list *p1=(struct list *)malloc(sizeof(struct list));
p1->data=data;
if(currentlevel==NULL)
{
p1->next=NULL;
currentlevel=p1;
}
else
{
p1->next=currentlevel;
currentlevel=p1;
}
}
void push1(int **data)
{
struct list *p11=(struct list *)malloc(sizeof(struct list));
p11->data=data;
if(nextlevel==NULL)
{
p11->next=NULL;
nextlevel=p11;
}
else
{
p11->next=nextlevel;
nextlevel=p11;
}
}