answersLogoWhite

0

The Josephus problem is a problem to locate the place for the last survivour. It shows the power of the circular linked list over the singly linked lists.

User Avatar

Wiki User

14y ago

What else can I help you with?

Continue Learning about Engineering

How society face the problem of scarcity?

how to solve ascarcity problem


What is a problem technology cannot solve?

Bullying


What problem did the invention of the dynamo solve?

This is dumb!


What problem might solar energy solve?

no


Insert algorithm for circular queue in data structures?

In a standard queue data structure re-buffering problem occurs for each dequeue operation. To solve this problem by joining the front and rear ends of a queue to make the queue as a circular queueCircular queue is a linear data structure. It follows FIFO principle.In circular queue the last node is connected back to the first node to make a circle.Circular linked list fallow the First In First Out principleElements are added at the rear end and the elements are deleted at front end of the queueBoth the front and the rear pointers points to the beginning of the array.It is also called as "Ring buffer".Items can inserted and deleted from a queue in O(1) time.Circular Queue can be created in three ways they are· Using single linked list· Using double linked list· Using arraysUsing single linked list:It is an extension for the basic single linked list. In circular linked list Instead of storing a Null value in the last node of a single linked list, store the address of the 1st node (root) forms a circular linked list. Using circular linked list it is possible to directly traverse to the first node after reaching the last node.The following figure shows circular single linked list:Using double linked listIn double linked list the right side pointer points to the next node address or the address of first node and left side pointer points to the previous node address or the address of last node of a list. Hence the above list is known as circular double linked list.The following figure shows Circular Double linked list :-Algorithm for creating circular linked list :-Step 1) startStep 2) create anode with the following fields to store information and the address of the next node.Structure nodebeginint infopointer to structure node called nextendStep 3) create a class called clist with the member variables of pointer to structure nodes called root, prev, next and the member functions create ( ) to create the circular linked list and display ( ) to display the circular linked list.Step 4) create an object called 'C' of clist typeStep 5) call C. create ( ) member functionStep 6) call C. display ( ) member functionStep 7) stopAlgorithm for create ( ) function:-Step 1) allocate the memory for newnodenewnode = new (node )Step 2) newnode->next=newnode. // circularStep 3) Repeat the steps from 4 to 5 until choice = 'n'Step 4) if (root=NULL)root = prev=newnode // prev is a running pointer which points last node of a listelsenewnode->next = rootprev->next = newnodeprev = newnodeStep 5) Read the choiceStep 6) returnAlgorithm for display ( ) function :-Step 1) startStep 2) declare a variable of pointer to structure node called temp, assign root to temptemp = rootStep 3) display temp->infoStep 4) temp = temp->nextStep 5) repeat the steps 6 until temp = rootStep 6) display temp infoStep 7) temp=temp->nextStep 8) returnUsing arrayIn arrays the range of a subscript is 0 to n-1 where n is the maximum size. To make the array as a circular array by making the subscript 0 as the next address of the subscript n-1 by using the formula subscript = (subscript +1) % maximum size. In circular queue the front and rear pointer are updated by using the above formula.The following figure shows circular array:Algorithm for Enqueue operation using arrayStep 1. startStep 2. if (front == (rear+1)%max)Print error "circular queue overflow "Step 3. else{ rear = (rear+1)%maxQ[rear] = element;If (front == -1 ) f = 0;}Step 4. stopAlgorithm for Dequeue operation using arrayStep 1. startStep 2. if ((front == rear) && (rear == -1))Print error "circular queue underflow "Step 3. else{ element = Q[front]If (front == rear) front=rear = -1ElseFront = (front + 1) % max}Step 4. stop

Related Questions

How did the cast of the core movie solve their problem?

because of circular flow of the earth is not balance


Does falsification solve the problem of induction?

No, the problem of induction is too circular to be solved. Read some Thomas s. Kuhn or Karl Popper.


The goal of applied science is?

It is to use science for a practical job or to solve a problem.


What is the difference between solving a problem and analyzing a problem?

When you analyze a problem you look it over which is what analyzing means. You look over the problem and then you solve it. When you solve a problem you solve it and you use certain steps and solve it but of course everyone has there ways to solve a problem but some people have ways to solve it by just analysing it. That is the difference.


What problem did the the trampoline solve?

It didn't solve any problem it was invented as a sport not as a way to solve anything...


Can sasol process solve south Africa's petrol problem?

no it can not solve the problem


How do you solve the problem of physical memory dump?

How do you solve the problem of physical memory dump?


How can geography solve the problem of street urchins?

how can geography solve the problem of street urchins?


What is the easiest way to solve algebra?

The easiest way to solve an algebra problem is to work out the problem.


What is the complex problem that you helped solve?

A complex problem I helped solve was when my friend was arguing with a girl .


What is the process of instruction the computer to solve a problem?

Programming is the process of instructing a computer to solve a problem.


How do you solve an or problem if a variable is unrestricted in sign?

Solve the problem using the + sign for the variable. Then solve the problem using the - sign for the variable. Report your answer as the answer that you got using + or the answer that you got using -.

Trending Questions
What is the need for limiter in FM receiver? HOW TO USE A screw-thread micrometer? How does garbage collection work in Vietnam? Can heating devices be made by passing an electric current through a conductor of high resistance low resistance high conductivity low conductivity? Why the grapics is not important feature in QBASIC? How much steel is required for one cubic meter of concrete? Why did he invent rubber? What is the HTML code for making a word stand out from he others? What is the salary of a civil engineering technician? Reverse of a number using do while? When you upload your HTML page in the public folder in the space allotted for you when you load the page you see that there is something written like index of your web address and a link to your HTML? Class D is derived from class B The class D does not contain any data members of its own Does the class D require constructors? Define concrete hollow block? Which three adapters customize and expand the capabilities of a computer? What is the difference between thread and virus? A company wants to transmit data over the telephone but it is concerned that its phones may be tapped All of its data is transmitted as four-digit integers It has asked you to write a program that? What is the code for Python grok learning 5? Who set the paint bomb because JJ had engineering books in Nancy Drew Danger by Design? What is the effect of increase value of a capacitor on ripple voltage? What happens in the circuit when a1N4001 diode experiences its breakdown voltage of 50V?