19 views

Uploaded by Vishnu Prasad Goranthala

cll

- Learn Data Structures With Myassignmenthelp.Net
- LinkedList Problems
- ADS-LAB MANUAL
- msQuestions
- asg 2
- Soft Dev Fund PPT 1.1
- CS6212 PDS Lab Manual CSE 2013 Regulations
- IT_3rd4thSem_2010_11
- ms_que
- 21338 - Limitations When Using ControlLogix
- Steganography Java
- BerryJam – Simple I2C Protocol for Advanced Communication Between Arduinos
- Slab Programs
- Structure
- Linked List
- S.Y.B.Tech-Syllabus-for-Print-compengg.pdf
- Data%20Strs%20using%20C%20EC401
- BSC PAPERII
- javaAU
- Capstone Chapter 4

You are on page 1of 6

A linked list in which the last node points to the first node is called a circular linked list. Circular linked lists avoid the use of null references in their nodes. Can be useful for certain algorithms like playing video/audio files repeatedly and ALT + TAB in Windows. Successor of tail node is the head node. In doubly-linked list, predecessor of head node is the tail node. Insertions and deletions into a circular linked list follow the same logic patterns used in a singly linked list except that the last node must always point to the first node. Therefore, when inserting or deleting the last node, in addition to updating the tail pointer, we must also point the link field of the new last node to the first node.

Advantage is that we can start searching from any node of the linked list and get to any other node. No logical head and tail pointers. However, we follow the conventions i.e., first element inserted into the list is given status of head and last element entered is called as a tail.

Some characteristics of Circular Linked list are that the Last node references the first node, every node has a successor, and no node in a circular linked list contains NULL. Defining a Circular Linked List: 1 #include <iostream> 2using namespace std; 3struct Node{ int data; 4 Node* next; 5 }; 6Node* NodePtr; 7

Insert into an empty Circular Linked list 1Node *loc = new Node; 2loc->data = 10; 3Tail = loc; 4Tail->next = Tail;

Insert to end of a Circular Linked List 1loc->next = Tail->next; 2Tail->next = loc; 3Tail = loc;

Delete a node from a single-node Circular Linked List 1Cur = Tail; 2Tail = NULL; 3delete Cur;

Delete the head node from a Circular Linked List 1Cur = Tail -> next; 2Tail->next = Cur->next 3delete Cur;

Delete the end node from a Circular Linked List 1Prev->next = Tail->next; 2delete Tail; 3Tail = Prev;

Ever wonder what to do if the integer size required by your program is greater than 232, 264, 2512, 21024? 4294967296 and greater CANNOT be handled by primitive int data type. What we can do is make use of linked lists. To Add two such long integers, their digits are traversed from right to left. The corresponding digits are added and the possible carry is added to the next digit. We store the integers from right to left in a list so that the first node contains the least significant digit (rightmost). And the last node contains the most significant digit (leftmost). We keep five digits in each node.

Algorithm

First let the user input two long integers Store the two long integers in the lists Both lists are traversed in parallel, and five digits are added at a time

If the sum of two 5 digits number is x, the lower order 5 digits of x can be extracted by using

o x % 100000 x / 100000

o

1 2 largeInt* addint (largeint *int1, largeint *int2) { 3 Node *p, q; 4 int hunthou = 100000; int carry, number, total; 5 largeint * sum; //defined to contain sum of p and q 6 sum = new largeint; 7 p = int1->Tail->Next; //p and q point to heads of list 8 q = int2->Tail->Next; 9 carry = 0; 10do 11{ //add info of two nodes and previous carry 12 total = p->data + q->data + carry; 13 //Determine lower order five digits 14 number = total % hunthou; 15 insertRear(sum, number); 16 //determine the carry carry = total / hunthou; 17 p = p ->next; 18 q = q->next 19} while ( p != int1->Tail->Next && q != int2->Tail->Next) 20 21while (p != int1->Tail->Next) { 22 total = p->data + carry; 23 number = total % hunthou; 24 insertRear(sum, number); 25 carry = total / hunthou; 26 p = p->next; } 27 28while (q != int2->Tail->Next) 29{ 30 total = q->data + carry; 31 number = total % hunthou; number); 32 insertRear(sum, carry = total / hunthou; 33 q = q->next; 34} 35 36if (carry == 1) 37{ insertRear (sum, carry); 38} 39 40return sum; 41} 42

43 44 45 46 47 48

Related Posts

The OpenGL Programming Guide Introduction to Recursion in C++ Functions with parameters in C++ Functions in C++ Repetition Control Statements in C++ C++ Expressions and Language Constructs Introduction to C++ Basics Mobile Developers Guide to the Parallel Universe Silverlight for Windows Phone Object-oriented Programming in C# for C and Java programmers

- Learn Data Structures With Myassignmenthelp.NetUploaded bySteveJohnson
- LinkedList ProblemsUploaded byGowreesan
- ADS-LAB MANUALUploaded byRaghu Teja
- msQuestionsUploaded byapi-3820391
- asg 2Uploaded byAbeer S
- Soft Dev Fund PPT 1.1Uploaded bykartikrao31
- CS6212 PDS Lab Manual CSE 2013 RegulationsUploaded byheyramzz
- IT_3rd4thSem_2010_11Uploaded bylambajitu
- ms_queUploaded byArdpler
- 21338 - Limitations When Using ControlLogixUploaded bymars_bruce_lee
- Steganography JavaUploaded byRishi Anand Pandey
- BerryJam – Simple I2C Protocol for Advanced Communication Between ArduinosUploaded bySigid Ariewibowo
- Slab ProgramsUploaded bysaumya
- StructureUploaded byCris Calitina
- Linked ListUploaded byPooja Trivedi
- S.Y.B.Tech-Syllabus-for-Print-compengg.pdfUploaded byHamza Demovireshsasin Motiwalla
- Data%20Strs%20using%20C%20EC401Uploaded byShashank M Chanmal
- BSC PAPERIIUploaded byvenugopalreddy
- javaAUUploaded bySatheesh Kumar
- Capstone Chapter 4Uploaded byGabriella Dane
- Format Types _ Bluetooth Technology WebsiteUploaded byAshok Siva Kumar Poojala
- Abdullah Shahid(0014)Uploaded byHaris
- DataStruc Lab ManualUploaded byAnkitSinghChauhan
- Pract List 3Uploaded byLakshay Bans
- 2013F CPCS 202 - Exam 1 - SolutionUploaded byOsama Maher
- Cot LTXUploaded byphong00x3
- adobe2Uploaded bySneha Mehra
- Computer Graphic ProgramsUploaded byriso
- L05 ArraysUploaded byTsion Kiffle
- He Syntax of the C Programming Language is a Set of Rules That Specifies Whether the Sequence of Characters in a File is Conforming C Source Code. TUploaded byvonaderty

- Chapter 11(Intrusion )Uploaded byVishnu Prasad Goranthala
- FPPTUploaded byVishnu Prasad Goranthala
- Chapter4 Basic C OperatorsUploaded byVishnu Prasad Goranthala
- gnu_c_tutUploaded byhallian3
- Logic Based Pattern Discovery NewUploaded byVishnu Prasad Goranthala
- Built in FunctionsUploaded byVishnu Prasad Goranthala
- tUploaded byVishnu Prasad Goranthala
- AVL treeUploaded byVishnu Prasad Goranthala
- Uploaded byJennifer Reynolds
- 08-SNMPUploaded byVishnu Prasad Goranthala
- PGPUploaded byVishnu Prasad Goranthala
- SNMPUploaded byVishnu Prasad Goranthala
- FirewallsUploaded byVishnu Prasad Goranthala
- Topic 10 Recursive BacktrackingUploaded byVishnu Prasad Goranthala
- StringsUploaded byVishnu Prasad Goranthala
- CccUploaded byVishnu Prasad Goranthala

- 'The Holy Prophet (Sallallaahu Álayhi Wasallam) has an education like that of childrenlunatics and animals of every category.' (Hifzul Imaan pg. 7)Uploaded bytousifkhan
- Down Syndrome Cognitive PhenotypeUploaded byNini Johanna
- LAUploaded byroslanchee
- Company Profile Sankalptech "MLM Software"Uploaded bySankalp Softwares
- 7b. Si Kristo Ay Gunitain (B)_UnisonUploaded byabrytau
- CTC_EALL_Hassaniyya.pdfUploaded byTiddukla Tadelsant Imedyazen
- Theory fileUploaded bynice_try_mate
- Subjective ObjectiveUploaded byVishnu Ronaldus Narayan
- English Functional XIIUploaded byAkshit Malhotra
- Bootstrap and Cross CompilerUploaded byricky_chawla_1
- Teaching Rhythm Logically by Darcy Potter Williams.pdfUploaded byVincent Bradlee Flieder
- Annual Report 2008Uploaded byKjartan Sigurðsson
- Seminar ReportUploaded byDona A. Fortes
- Reading and Writing - Unit 5 - Tn1Uploaded byRomario JC
- Propaganda TechniquesUploaded byAlyanna Crisologo
- Unit2 LexisUploaded byEnier Antonio Guerrero Vergel
- UML-1Uploaded byAsher Shamim
- NounUploaded by矢澤 ニコ
- 3 đề HCMUploaded byHồ Viết Tiên
- Call of Cthulhu - Secrets of the KremlinUploaded byperry spiropoulos
- Lesson - i Have a Dream - Martin Luther King (New Version)Uploaded byMichael M.
- happy house1 teachers_resource_book_new.pdfUploaded byLara Vigil González
- FeminismUploaded byKaushik Ray
- Sherry by Talia Baiocchi - Recipes and ExcerptUploaded byCrown Publishing Group
- Lecture 8 Benefits of PlayUploaded byHasidah Idasha
- Joint Commission Patient-Centered Communication Standards 2011Uploaded byInstitute of California
- Vivado TutorialUploaded bythanhvnpt
- How to DevelopUploaded byapi-3701437
- Programming the Raspberry PiUploaded byheap
- Ppt Report TextUploaded byyansautamaswandari