Already have an account? Get multiple benefits of using own account!
Login in your account..!
Remember me
Don't have an account? Create your account in less than a minutes,
Forgot password? how can I recover my password now!
Enter right registered email to receive password!
Q. Perform implementation of a queue using a singly linked list L. The operations INSER and DELETE should take O (1) time.
Ans:
Implementation of queue by using a singly linked list: When implement a queue as a single liked list, a queue q consists of a list and two pointers, q.front and the q.rear. inserting an element is stated below: insert(q,x) { p=getnode(); info(p) = x; next(p) = null; if(q.rear == null) q.front = p; else next(q.rear) = p; q.rear = p; } deletion is stated below: remove(q) { if(empty(q)) { printf("queue overflow"); exit(1); } p=q.front; x=info(p); q.front=next(p); if(q.front == null) q.rear = null; freenode(p); return(x); }
Implementation of queue by using a singly linked list:
When implement a queue as a single liked list, a queue q consists of a list and two pointers, q.front and the q.rear.
inserting an element is stated below:
insert(q,x)
{
p=getnode(); info(p) = x; next(p) = null; if(q.rear == null)
q.front = p;
else
next(q.rear) = p;
q.rear = p;
}
deletion is stated below:
remove(q)
if(empty(q))
printf("queue overflow");
exit(1);
p=q.front; x=info(p); q.front=next(p); if(q.front == null) q.rear = null; freenode(p); return(x);
Q.1 Write procedures/ Algorithm to insert and delete an element in to array. Q.2. Write an algorithm for binary search. What are the conditions under which sequential search of
algorithm for multiplication of two sparse matrices using linked lists..
1. Write a pseudocode algorithm to print the numbers from 1 to 10, and then from 10 to 1, using exactly one loop. 2. The function contains() takes a food as an argument and tell
for (i = 0; i sequence of statements } Here, the loop executes n times. Thus, the sequence of statements also executes n times. Since we suppose the time complexity of th
First - Fit Method: - The free list is traversed sequentially to search the 1st free block whose size is larger than or equal to the amount requested. Once the block is found it
Suppose there are exactly five packet switches (Figure 4) between a sending host and a receiving host connected by a virtual circuit line (shown as dotted line in figure 4). The tr
Suppose we have a set of N agents and a set of N tasks.Each agent can only perform exactly one task and there is a cost associated with each assignment. We would like to find out a
AVL trees and the nodes it contains must meet strict balance requirements to maintain O(log n) search time. These balance restrictions are kept maintained via various rotation func
What are the different ways of representing a graph? The different ways of representing a graph is: Adjacency list representation: This representation of graph having of an
traverse the graph as BFS
Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!
whatsapp: +1-415-670-9521
Phone: +1-415-670-9521
Email: [email protected]
All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd