id int64 0 25.6k | text stringlengths 0 4.59k |
|---|---|
24,400 | data structures using return start/had to be added output *****main menu **** create list display the list add node at the beginning add the node at the end add the node before given node add the node after given node delete node from the beginning delete node from the end delete given node delete node after given node... |
24,401 | start (biology start (computer science figure roll no next memory representation of two circular linked lists stored in the memory the last node of the list when we traverse the data and next in this mannerwe will finally see that the linked list in fig stores characters that when put together form the word hello nowlo... |
24,402 | data structures using figure shows the algorithm to insert new node at the beginning of linked list in step we first check whether memory is available for the new node if the free memory has exhaustedthen an overflow message is printed otherwiseif free memory cell is availablethen we allocate space for the new node set... |
24,403 | deletion are same as that given for singly linked lists step if avail null write overflow go to step [end of ifstep set new_node avail step set avail avail -next step set new_node -data val step set new_node -next start step set ptr start step repeat step while ptr -next !start step set ptr ptr -next [end of loopstep s... |
24,404 | data structures using start take two pointers preptr and ptr which will initially point to start start preptr ptr move ptr so that it points to the last node of the list preptr will always point to the node preceding ptr preptr ptr start make the preptr' next part store start node' address and free the space allocated ... |
24,405 | struct node *delete_beg(struct node *)struct node *delete_end(struct node *)struct node *delete_after(struct node *)struct node *delete_list(struct node *)int main(int optionclrscr()do printf("\ \ *****main menu *****")printf("\ create list")printf("\ display the list")printf("\ add node at the beginning")printf("\ add... |
24,406 | data structures using start new_nodeelse ptr startwhile(ptr -next !startptr ptr -nextptr -next new_nodenew_node -next startprintf("\ enter the data ")scanf("% "&num)return startstruct node *display(struct node *startstruct node *ptrptr=startwhile(ptr -next !startprintf("\ % "ptr -data)ptr ptr -nextprintf("\ % "ptr -dat... |
24,407 | while(ptr -next !startptr ptr -nextptr -next start -nextfree(start)start ptr -nextreturn startstruct node *delete_end(struct node *startstruct node *ptr*preptrptr startwhile(ptr -next !startpreptr ptrptr ptr -nextpreptr -next ptr -nextfree(ptr)return startstruct node *delete_after(struct node *startstruct node *ptr*pre... |
24,408 | data structures using enter the data enter the data- circular linked list created enter your option enter your option enter your option enter your option doubly linked lists doubly linked list or two-way linked list is more complex type of linked list which contains pointer to the next as well as the previous node in t... |
24,409 | case the new node is inserted at the end case the new node is inserted after given node case the new node is inserted before given node inserting node at the beginning of doubly linked list consider the doubly linked list shown in fig suppose we want to add new node with data as the first node of the list then the foll... |
24,410 | data structures using figure shows the algorithm to insert new node at the end of doubly linked list in step we take pointer variable ptr and initialize it with start in the while loopwe traverse through the linked list to reach the last node once we reach the last nodein step we change the next pointer of the last nod... |
24,411 | step if avail null write overflow go to step [end of ifstep set new_node avail step set avail avail -next step set new_node -data val step set ptr start step repeat step while ptr -data !num step set ptr ptr -next [end of loopstep set new_node -next ptr step set new_node -prev ptr -prev step set ptr -prev new_node step... |
24,412 | data structures using case the first node is deleted case the last node is deleted case the node after given node is deleted case the node before given node is deleted deleting the first node from doubly linked list consider the doubly linked list shown in fig when we want to delete node from the beginning of the listt... |
24,413 | step if start null write underflow go to step [end of ifstep set ptr start step repeat step while ptr -next !null step set ptr ptr -next [end of loopstep set ptr -prev -next null step free ptr step exit figure algorithm to delete the last node figure shows the algorithm to delete the last node of doubly linked list in ... |
24,414 | data structures using deleting the node before given node in doubly linked list consider the doubly linked list shown in fig suppose we want to delete the node preceding the node with value before discussing the changes that will be done in the linked listlet us first look at the algorithm start take pointer variable p... |
24,415 | struct node struct node *nextint datastruct node *prev}struct node *start nullstruct node *create_ll(struct node *)struct node *display(struct node *)struct node *insert_beg(struct node *)struct node *insert_end(struct node *)struct node *insert_before(struct node *)struct node *insert_after(struct node *)struct node *... |
24,416 | data structures using breakcase start delete_list(start)printf("\ doubly linked list deleted")break}while(option ! )getch()return struct node *create_ll(struct node *startstruct node *new_node*ptrint numprintf("\ enter - to end")printf("\ enter the data ")scanf("% "&num)while(num !- if(start =nullnew_node (struct node*... |
24,417 | start -prev new_nodenew_node -next startnew_node -prev nullstart new_nodereturn startstruct node *insert_end(struct node *startstruct node *ptr*new_nodeint numprintf("\ enter the data ")scanf("% "&num)new_node (struct node *)malloc(sizeof(struct node))new_node -data numptr=startwhile(ptr -next !nullptr ptr -nextptr -ne... |
24,418 | data structures using struct node *delete_beg(struct node *startstruct node *ptrptr startstart start -nextstart -prev nullfree(ptr)return startstruct node *delete_end(struct node *startstruct node *ptrptr startwhile(ptr -next !nullptr ptr -nextptr -prev -next nullfree(ptr)return startstruct node *delete_after(struct no... |
24,419 | output *****main menu **** create list display the list delete the entire list exit enter your option enter - to end enter the data enter the data enter the data enter the data- doubly linked list created enter your option circular doubly linked lists circular doubly linked list or circular two-way linked list is more ... |
24,420 | data structures using inserting new node in circular doubly linked list in this sectionwe will see how new node is added into an already existing circular doubly linked list we will take two cases and then see how insertion is done in each case rest of the cases are similar to that given for doubly linked lists case th... |
24,421 | inserting node at the end of circular doubly linked list consider the circular doubly linked list shown in fig suppose we want to add new node with data as the last node of the list then the following changes will be done in the linked list start allocate memory for the new node and initialize its data part to take poi... |
24,422 | data structures using start take pointer variable ptr that points to the first node of the list startptr move ptr further so that it now points to the last node of the list ptr start make start point to the second node of the list free the space occupied by the first node start figure deleting the first node from circu... |
24,423 | step if start null write underflow go to step [end of ifstep set ptr start step repeat step while ptr -next !start step set ptr ptr -next [end of loopstep set ptr -prev -next start step set start -prev ptr -prev step free ptr step exit figure algorithm to delete the last node figure shows the algorithm to delete the la... |
24,424 | data structures using scanf("% "&option)switch(optioncase start create_ll(start)printf("\ circular doubly linked list created")breakcase start display(start)breakcase start insert_beg(start)breakcase start insert_end(start)breakcase start delete_beg(start)breakcase start delete_end(start)breakcase start delete_node(sta... |
24,425 | return startstruct node *display(struct node *startstruct node *ptrptr startwhile(ptr -next !startprintf("\ % "ptr -data)ptr ptr -nextprintf("\ % "ptr -data)return startstruct node *insert_beg(struct node *startstruct node *new_node*ptrint numprintf("\ enter the data ")scanf("% "&num)new_node (struct node *)malloc(size... |
24,426 | data structures using struct node *delete_end(struct node *startstruct node *ptrptr=startwhile(ptr -next !startptr ptr -nextptr -prev -next startstart -prev ptr -prevfree(ptr)return startstruct node *delete_node(struct node *startstruct node *ptrint valprintf("\ enter the value of the node which has to be deleted ")sca... |
24,427 | header linked lists header linked list is special type of linked list which contains header node at the beginning of the list soin header linked liststart will not point to the first node of the list but start will contain the address of the header node the following are the two variants of header linked listgrounded h... |
24,428 | data structures using step if avail null write overflow go to step [end of ifstep set new_node avail step set avail avail -next step set ptr start -next step set new_node -data val step repeat step while ptr -data !num step set ptr ptr -next [end of loopstep new_node -next ptr -next step set ptr -next new_node step exi... |
24,429 | case start display(start)break}while(option != )getch()return struct node *create_hll(struct node *startstruct node *new_node*ptrint numprintf("\ enter - to end")printf("\ enter the data ")scanf("% "&num)while(num!=- new_node (struct node*)malloc(sizeof(struct node))new_node->data=numnew_node->next=nullif(start==nullst... |
24,430 | data structures using multi-linked lists in multi-linked listeach node can have number of pointers to other nodes doubly linked list is special case of multi-linked lists howeverunlike doubly linked listsnodes in multilinked list may or may not have inverses for each pointer we can differentiate doubly linked list from... |
24,431 | the matrix howeveras in case of doubly linked listswe can also have corresponding inverse pointer for every pointer in the multi-linked list representation of sparse matrix note when non-zero value in the sparse matrix is set to zerothe corresponding node in the multi-linked list must be deleted ( null null null co-ord... |
24,432 | data structures using programming example write program to store polynomial using linked list alsoperform addition and subtraction on two polynomials #include #include #include struct node int numint coeffstruct node *next}struct node *start nullstruct node *start nullstruct node *start nullstruct node *start nullstruc... |
24,433 | break}while(option!= )getch()return struct node *create_poly(struct node *startstruct node *new_node*ptrint ncprintf("\ enter the number ")scanf("% "& )printf("\ enter its coefficient ")scanf("% "& )while( !- if(start==nullnew_node (struct node *)malloc(sizeof(struct node))new_node -num nnew_node -coeff cnew_node -next... |
24,434 | data structures using ptr start ptr start while(ptr !null &ptr !nullif(ptr -coeff =ptr -coeffsum_num ptr -num ptr -numstart add_node(start sum_numptr -coeff)ptr ptr -nextptr ptr -nextelse if(ptr -coeff ptr -coeffstart add_node(start ptr -numptr -coeff)ptr ptr -nextelse if(ptr -coeff coeffstart add_node(start ptr -numpt... |
24,435 | start add_node(start ptr -numptr -coeff)ptr ptr -next}while(ptr !null |ptr !null)if(ptr =nullwhile(ptr !nullstart add_node(start ptr -numptr -coeff)ptr ptr -nextif(ptr =nullwhile(ptr !nullstart add_node(start ptr -numptr -coeff)ptr ptr -nextreturn start struct node *add_node(struct node *startint nint cstruct node *ptr... |
24,436 | data structures using points to remember linked list is linear collection of data elements called as nodes in which linear representation is given by links from one node to another linked list is data structure which can be used to implement other data structures such as stacksqueuesand their variations before we inser... |
24,437 | create linked list which stores names of the employees then sort these names and re-display the contents of the linked list programming exercises write program that removes all nodes that have duplicate information write program to print the total number of occurrences of given item in the linked list write program to ... |
24,438 | data structures using write program to delete node from circular header linked list write program to delete all nodes from header linked list that has negative values in its data part multiple-choice questions linked list is (arandom access structure (bsequential access structure (cboth (dnone of these an array is (ara... |
24,439 | stacks learning objective stack is an important data structure which is extensively used in computer applications in this we will study about the important features of stacks to understand how and why they organize the data so uniquely the will also illustrate the implementation of stacks by using both arrays as well a... |
24,440 | data structures using function function function function when calls ba is pushed on top of the system stack when the execution of is completethe system control will remove from the stack and continue with its execution when calls dc is pushed on top of the system stack when the execution of is completethe system contr... |
24,441 | operations on stack stack supports three basic operationspushpopand peek the push operation adds an element to the top of the stack and the pop operation removes the element from the top of the stack the peek operation returns the value of the topmost element of the stack push operation the push operation is used to in... |
24,442 | data structures using peek operation peek is an operation that returns the value of the topmost element of the stack without deleting it from the stack the algorithm for peek operation is given in fig howeverthe peek operation first checks if the stack is emptyi if top nullthen an appropriate message is printedelse the... |
24,443 | printf("\ the value stored at top of stack is% "val)breakcase display(st)break}while(option ! )return void push(int st[]int valif(top =max- printf("\ stack overflow")else top++st[topvalint pop(int st[]int valif(top =- printf("\ stack underflow")return - else val st[top]top--return valvoid display(int st[]int iif(top =-... |
24,444 | data structures using output *****main menu**** push pop peek display exit enter your option enter the number to be pushed on stack linked representation of stacks we have seen how stack is created using an array this technique of creating stack is easybut the drawback is that the array must be declared to have some fi... |
24,445 | step allocate memory for the new node and name it as new_node step set new_node -data val step if top null set new_node -next null set top new_node else set new_node -next top set top new_node [end of ifstep end is done by checking if top null in case the if statement evaluates to truethen null is stored in the next pa... |
24,446 | data structures using do printf("\ *****main menu*****")printf("\ push")printf("\ pop")printf("\ peek")printf("\ display")printf("\ exit")printf("\ enter your option")scanf("% "&option)switch(optioncase printf("\ enter the number to be pushed on stack")scanf("% "&val)top push(topval)breakcase top pop(top)breakcase val ... |
24,447 | while(ptr !nullprintf("\ % "ptr -data)ptr ptr -nextreturn topstruct stack *pop(struct stack *topstruct stack *ptrptr topif(top =nullprintf("\ stack underflow")else top top -nextprintf("\ the value being deleted is% "ptr -data)free(ptr)return topint peek(struct stack *topif(top==nullreturn - else return top ->dataoutput... |
24,448 | data structures using these stacksit is important to note one thing--stack will grow from left to rightwhereas stack will grow from right to left at the same time extending this concept to multiple stacksa stack can also be used to represent number of stacks in the same array that isif we have stack[ ]then each stack w... |
24,449 | topb - stack[topbvalint popb(int valif(topb==maxprintf("\ underflow")val - else val stack[topb]topb++void display_stackb(int iif(topb==maxprintf("\ stack is empty")else for( =topb; <max; ++printf("\ % ",stack[ ])void main(int optionvalclrscr()do printf("\ *****menu*****")printf("\ push in stack ")printf("\ push in stac... |
24,450 | data structures using case val=popb()if(val!=- printf("\ the value popped from stack % ",val)breakcase printf("\ the contents of stack are \ ")display_stacka()breakcase printf("\ the contents of stack are \ ")display_stackb()break}while(option!= )getch()output *****main menu**** push in stack push in stack pop from sta... |
24,451 | #include int stk[ ]int top=- int pop()void push(int)int main(int valniarr[ ]clrscr()printf("\ enter the number of elements in the array ")scanf("% "& )printf("\ enter the elements of the array ")for( = ; < ; ++scanf("% "&arr[ ])for( = ; < ; ++push(arr[ ])for( = ; < ; ++val pop()arr[ivalprintf("\ the reversed array is "... |
24,452 | char pop()void main(char exp[max],tempint iflag= clrscr()printf("enter an expression ")gets(exp)for( = ; <strlen(exp); ++if(exp[ ]=='(|exp[ ]=='{|exp[ ]=='['push(exp[ ])if(exp[ ]==')|exp[ ]=='}|exp[ ]==']'if(top =- flag= else temp=pop()if(exp[ ]==')&(temp=='{|temp=='[')flag= if(exp[ ]=='}&(temp=='(|temp=='[')flag= if(e... |
24,453 | while writing an arithmetic expression using infix notationthe operator is placed in between the operands for examplea+bhereplus operator is placed between the two operands and although it is easy for us to write expressions using infix notationcomputers find it difficult to parse as the computer needs lot of informati... |
24,454 | data structures using the algorithm given below transforms an infix expression into postfix expressionas shown in fig the algorithm accepts an infix expression that may contain operatorsoperandsand parentheses for simplicitywe assume that the infix operation contains only modulus (%)multiplication (*)division (/)additi... |
24,455 | void infixtopostfix(char source[]char target[])int getpriority(char)int main(char infix[ ]postfix[ ]clrscr()printf("\ enter any infix expression ")gets(infix)strcpy(postfix"")infixtopostfix(infixpostfix)printf("\ the corresponding postfix expression is ")puts(postfix)getch()return void infixtopostfix(char source[]char ... |
24,456 | data structures using printf("\ incorrect element in expression")exit( )while((top!=- &(st[top]!='(')target[jpop(st) ++target[ ]='\ 'int getpriority(char opif(op=='/|op ='*|op=='%'return else if(op=='+|op=='-'return void push(char st[]char valif(top==max- printf("\ stack overflow")else top++st[top]=valchar pop(char st[... |
24,457 | table evaluation of postfix expression character scanned figure stack algorithm to evaluate postfix expression let us now take an example that makes use of this algorithm consider the infix expression given as (( evaluate the expression the infix expression (( can be written as using postfix notation look at table whic... |
24,458 | data structures using push(st(float)(exp[ ]-' '))else op pop(st)op pop(st)switch(exp[ ]case '+'value op op breakcase '-'value op op breakcase '/'value op op breakcase '*'value op op breakcase '%'value (int)op (int)op breakpush(stvalue) ++return(pop(st))void push(float st[]float valif(top==max- printf("\ stack overflow"... |
24,459 | step scan each character in the infix expression for thisrepeat steps - until the end of infix expression step push the operator into the operator stackoperand into the operand stackand ignore all the left parentheses until right parenthesis is encountered step pop operand from operand stack step pop operand from opera... |
24,460 | data structures using printf("\ the prefix expression is \ ")puts(temp)getch()return void reverse(char str[]int leni= = len=strlen(str) =len- while( > if (str[ ='('temp[ ')'else if str[ =')'temp[ '('else temp[istr[ ] ++ --temp[ '\ 'void infixtopostfix(char source[]char target[]int = = char tempstrcpy(target"")while(sou... |
24,461 | getpriority(source[ ]))target[jpop(st) ++push(stsource[ ]) ++else printf("\ incorrect element in expression")exit( )while((top!=- &(st[top]!='(')target[jpop(st) ++target[ ]='\ 'int getprioritychar opif(op=='/|op ='*|op=='%'return else if(op=='+|op=='-'return void push(char st[]char valif(top==max- printf("\ stack overf... |
24,462 | data structures using for exampleconsider the prefix expression let us now apply the algorithm to evaluate this expression programming example write program to evaluate prefix expression figure algorithm for evaluation of prefix expression character scanned operand stack #include #include #include int stk[ ]int top=- i... |
24,463 | int pop(return(stk[top--])int get_type(char cif( ='+| ='-| ='*| ='/'return else return output enter the prefix expression +- result recursion in this section we are going to discuss recursion which is an implicit application of the stack adt recursive function is defined as function that calls itself to solve smaller v... |
24,464 | data structures using factorial of number every recursive function must have base case and recursive case for the factorial functionbase case is when because if the result will be as programming tip every recursive function must recursive case of the factorial function will call itself but with have at least one base c... |
24,465 | here we assume that however if bthen interchange and in the formula given above working assume and gcd( rem gcd( rem gcd( rem return return return programming example write program to calculate the gcd of two numbers using recursive functions #include int gcd(intint)int main(int num num resprintf("\ enter the two numbe... |
24,466 | data structures using exp_rec( exp_rec( programming example write program to calculate exp( ,yusing recursive functions #include int exp_rec(intint)int main(int num num resprintf("\ enter the two numbers")scanf("% % "&num &num )res exp_rec(num num )printf ("\ result % "res)return int exp_rec(int xint yif( == return els... |
24,467 | printf("% \ ",res)return int fibonacci(int nif = return else if = return else return fibonacci( - fibonacci( - )output enter the number of terms fibonacci series types of recursion recursion is technique that breaks problem into one or more sub-problems that are similar to the original problem any recursive function ca... |
24,468 | whenever there is pending operation to be performedthe function becomes non-tail recursive in such non-tail recursive functioninformation about each pending operation must be storedso the amount of information directly depends on the number of calls howeverthe same factorial function can be written in tailrecursive man... |
24,469 | figure tower of hanoi figure move rings from to figure move ring from to figure move ring from to look at fig which shows three rings mounted on pole the problem is to move all these rings from pole to pole while maintaining the same order the main issue is that the smaller disk must always come above the larger disk w... |
24,470 | data structures using howeverrecursive solutions are not always the best solutions in some casesrecursive programs may require substantial amount of run-time overhead thereforewhen implementing recursive solutionthere is trade-off involved between the time spent in constructing and maintaining the program and the cost ... |
24,471 | the drawbacks/disadvantages of using recursive program include the followingfor some programmers and readersrecursion is difficult concept recursion is implemented using system stack if the stack space on the system is limitedrecursion to deeper level will be difficult to implement aborting recursive program in midstre... |
24,472 | data structures using (aa (babc give the infix expression of the following prefix expressions (aa (ba convert the expression given below into its corresponding postfix expression and then evaluate it also write program to evaluate postfix expression (( )/ write function that accepts two stacks copy the contents of firs... |
24,473 | queues learning objective queue is an important data structure which is extensively used in computer applications in this we will study the operations that can be performed on queue the will also discuss the implementation of queue by using both arrays as well as linked lists the will illustrate different types of queu... |
24,474 | data structures using array representation of queues queues can be easily represented using linear arrays as stated earlierevery queue has front and rear variables that point to the position from where deletions and insertions can be donerespectively the array representation of queue is shown in fig operations on queue... |
24,475 | #define max /changing this value will change length of array int queue[max]int front - rear - void insert(void)int delete_element(void)int peek(void)void display(void)int main(int optionvaldo printf("\ \ ****main menu *****")printf("\ insert an element")printf("\ delete an element")printf("\ peek")printf("\ display the... |
24,476 | data structures using if(front =- |front>rearprintf("\ underflow")return - else val queue[front]front++if(front rearfront rear - return valint peek(if(front==- |front>rearprintf("\ queue is empty")return - else return queue[front]void display(int iprintf("\ ")if(front =- |front rearprintf("\ queue is empty")else for( f... |
24,477 | be wasted and in case we allocate less memory locations for queue that might end up growing large and largethen lot of re-allocations will have to be donethereby creating lot of overhead and consuming lot of time in case the queue is very small one or its maximum size is known in advancethen the array implementation of... |
24,478 | data structures using delete operation the delete operation is used to delete the element that is first inserted in queuei the element whose address is stored in front howeverbefore deleting the valuewe must first check if front=null because if this is the casethen the queue is empty and no more deletions can be done i... |
24,479 | printf("\ peek")printf("\ display")printf("\ exit")printf("\ enter your option ")scanf("% "&option)switch(optioncase printf("\ enter the number to insert in the queue:")scanf("% "&val) insert( ,val)breakcase delete_element( )breakcase val peek( )if(val- printf("\ the value at front of queue is % "val)breakcase display(... |
24,480 | data structures using while(ptr!= -rearprintf("% \ "ptr -data)ptr ptr -nextprintf("% \ "ptr -data)return qstruct queue *delete_element(struct queue *qstruct node *ptrptr -frontif( -front =nullprintf("\ underflow")else -front -front -nextprintf("\ the value being deleted is % "ptr -data)free(ptr)return qint peek(struct ... |
24,481 | nowif you want to insert another valueit will not be possible because the queue is completely full there is no empty space where the value can be inserted consider scenario in which two successive deletions are made the queue will then be given as shown in fig figure queue after two successive deletions herefront and r... |
24,482 | data structures using front rear - figure empty queue front rear delete this element and set rear front - figure queue with single element rear front look at fig if front - then there are no elements in the queue soan underflow condition will be reported if the queue is not empty and front rearthen after deleting the e... |
24,483 | printf("\ the number deleted is % "val)breakcase val peek()if(val!=- printf("\ the first value in queue is % "val)breakcase display()break}while(option!= )getch()return void insert(int numprintf("\ enter the number to be inserted in the queue ")scanf("% "&num)if(front== &rear==max- printf("\ overflow")else if(front==- ... |
24,484 | data structures using else return queue[front]void display(int iprintf("\ ")if (front ==- &rear=- printf ("\ queue is empty")else if(front<rearfor( =front; <=rear; ++printf("\ % "queue[ ])else for( =front; <max; ++printf("\ % "queue[ ])for( = ; <=rear; ++printf("\ % "queue[ ])output ****main menu **** insert an element... |
24,485 | programming example write program to implement input and output restricted deques #include #include #define max int deque[max]int left - right - void input_deque(void)void output_deque(void)void insert_left(void)void insert_right(void)void delete_left(void)void delete_right(void)void display(void)int main(int optionclr... |
24,486 | data structures using void output_deque(int optiondo printf("output restricted deque")printf("\ insert at right")printf("\ insert at left")printf("\ delete from left")printf("\ display")printf("\ quit")printf("\ enter your option ")scanf("% ",&option)switch(optioncase insert_right()breakcase insert_left()breakcase dele... |
24,487 | if (left =- )/*if queue is initially empty*left right else if(left = left=max- else left=left- deque[leftvalvoid delete_left(if (left =- printf("\ underflow")return printf("\ the deleted element is % "deque[left])if(left =right/*queue has only one element *left - right - else if(left =max- left else left left+ void del... |
24,488 | data structures using if(front <rear while(front <rearprintf("% ",deque[front])front++else while(front <max- printf("% "deque[front])front++front while(front <rearprintf("% ",deque[front])front++printf("\ ")output ****main menu **** input restricted deque output restricted deque enter your option input restricted deque... |
24,489 | and the second with printing of stock detailsthen obviously the online booking is more important and must be executed first implementation of priority queue there are two ways to implement priority queue we can either use sorted list to store the elements so that when an element has to be taken outthe queue will not ha... |
24,490 | data structures using howeverif we have new element with data and priority number then the element will be inserted after bas both these elements have the same priority but the insertions are done on fcfs basis as shown in fig figure priority queue after insertion of new node deletion deletion is very simple process in... |
24,491 | struct node *start=nullstruct node *insert(struct node *)struct node *delete(struct node *)void display(struct node *)int main(int optionclrscr()do printf("\ *****main menu*****)printf("\ insert")printf("\ delete")printf("\ display")printf("\ exit")printf("\ enter your option ")scanf"% "&option)switch(optioncase start=... |
24,492 | data structures using ptr startprintf("\ deleted item is% "ptr->data)start start->nextfree(ptr)return startvoid display(struct node *startstruct node *ptrptr startif(start =nullprintf("\nqueue is empty)else printf("\ priority queue is )while(ptr !nullprintf"\ % [priority=% ]"ptr->dataptr->priority )ptr=ptr->nextoutput ... |
24,493 | programming example write program to implement multiple queues #include #include #define max int queue[max]reara=- ,fronta=- rearb=maxfrontb maxvoid inserta(int valif(reara==rearb - printf("\ overflow")else if(reara ==- &fronta =- reara fronta queue[rearavalelse queue[++rearavalint deletea(int valif(fronta==- printf("\... |
24,494 | data structures using int deleteb(int valif(frontb==maxprintf("\ underflow")return - else val queue[frontb]frontb--if (frontb<rearbfrontb=rearb=maxreturn valvoid display_queueb(int iif(frontb==maxprintf("\ queue is empty")else for( =frontb; >=rearb; --printf("\ % ",queue[ ])int main(int optionvalclrscr()do printf("\ **... |
24,495 | printf("\ the value deleted from queue % ",val)breakcase printf("\ the contents of queue are \ ")display_queuea()breakcase printf("\ the contents of queue are \ ")display_queueb()break}while(option!= )getch()output *******menu****** insert in queue insert in queue delete from queue delete from queue display queue displ... |
24,496 | data structures using try the same process with and = you will find that person at position is the winner the elimination goes in the sequence of and programming example write program which finds the solution of josephus problem using circular linked list #include #include #include struct node int player_idstruct node ... |
24,497 | points to remember queue is fifo data structure in which the element that is inserted first is the first one to be taken out the elements in queue are added at one end called the rear and removed from the other end called the front in the computer ' memoryqueues can be implemented using both arrays and linked lists the... |
24,498 | data structures using write program to implement priority queue write program to create queue from stack write program to create stack from queue write program to reverse the elements of queue write program to input two queues and compare their contents multiple-choice questions line in grocery store represents (astack... |
24,499 | trees learning objective so farwe have discussed linear data structures such as arraysstringsstacksand queues in this we will learn about non-linear data structure called tree tree is structure which is mainly used to store data that is hierarchical in nature in this we will first discuss general trees and then binary ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.