×
Everything you do now is for your future. Think About that.
--Your friends at LectureNotes
Close

Data Structure using C

by Keshav Kr
Type: NoteInstitute: College Course: B.Tech Specialization: Computer Science EngineeringViews: 9Uploaded: 7 months agoAdd to Favourite

Share it with your friends

Suggested Materials

Leave your Comments

Contributors

Keshav Kr
Keshav Kr
Singly Linked List Traversal 1. ptr=start 2. Repeat while ptr!=NULL (a) Apply process to ptr->info (b) ptr=ptr->next 3. Exit. Searching in Unsorted List 1. ptr=start 2. Repeat while ptr!=NULL and ptr->info!=value (a) ptr=ptr->next 3. If ptr=NULL Then Print “Element Not Found” Else Print “Element Found” 4. Exit. Searching in Sorted List 1. ptr=start 2. Repeat while ptr!=NULL (a) If ptr->info=value Then Print “Element Found’ Else If ptr->info<value Then Print “Element Not Found” Else ptr=ptr->next 3. Exit. Insertion at Beginning 1. 2. 3. 4. 5. 6. Create a node temp. If temp=NULL then Print “Overflow” and Exit. temp->info=value temp->next=start start=temp Exit. Insertion at End 1. 2. 3. 4. Create a node temp. If temp=NULL Then Print “Overflow” and Exit. temp->info=value and temp->next=NULL If start=NULL Then start=temp
Else (a) ptr=start (b) Repeat while ptr->next!=NULL (i) ptr=ptr->next (c) ptr->next=temp 5. Exit. Insertion after a given node with key ‘K’ 1. 2. 3. 4. 5. If start=NULL Then Print “List is Empty” and Exit. Create a node temp If temp=NULL Then Print “Overflow” and Exit. ptr=start Repeat while ptr=NULL and ptr->info!=K (a) ptr=ptr->next 6. 7. 8. 9. 10. if ptr=NULL Then Print “No node with key ‘K’ exist” and Exit. temp->info=value temp->next=ptr->next ptr->next=temp Exit. Insertion after a given node 1. 2. 3. 4. 5. 6. Create a node temp. If temp=NULL Then Print “Overflow” and Exit. temp->info=value temp->next=node->next node->next=temp Exit. Deletion at Beginning 1. 2. 3. 4. 5. 6. If start=NULL Then Print “Underflow” and Exit. Print start->info i.e. the element to be deleted. temp=start start=start->next free(temp) Exit. Deletion at End 1. If start=NULL Then Print “Underflow” and Exit. 2. ptr=start 3. If start->next=NULL
Then start=NULL Else (a) ptr1=ptr and ptr=ptr->next (b) Repeat while ptr->next!=NULL ptr1=ptr and ptr=ptr->next (c) ptr->next=NULL 4. free(ptr) 5. Exit. Circular Linked List Traversal 1. 2. 3. 4. If start=NULL Then Print “List is Empty” and Exit. Apply process to start->info ptr=start->next Repeat while ptr!=start (a) Apply process to start->info (b) ptr=ptr->next 5. Exit. Searching in a Unsorted List 1. If start=NULL Then Print “List is empty” and Exit. 2. ptr=start 3. Repeat while ptr->next!=start and ptr->info!=value (a) Ptr=ptr->next 4. If ptr->info=value Then Print “Element Found” Else Print “Element not Found” 5. Exit. Searching in a Sorted List 1. If start=NULL Then Print “List is Empty” and Exit. 2. ptr=start 3. Repeat while ptr->next!=start (a) If ptr->info=value Then Print “Element Found” and Exit. (b) If ptr->info<value Then Print “Element Not Found” and Exit. (c) ptr=ptr->next 4. If ptr->info=key Then Print “Element Found” Else Print “Element Not Found” 5. Exit.
Insertion at Beginning 1. 2. 3. 4. Create a node temp. If temp=NULL Then Print “Overflow” and Exit. temp->info=value If start=NULL Then temp->next=temp Else (a) temp->next=start (b) ptr=start (c) Repeat while ptr->next!=start ptr=ptr->next (d) ptr->next=temp 5. start=temp 6. Exit. Insertion at End 1. 2. 3. 4. Create a node temp. If temp=NULL Then Print “Overflow” and Exit. temp->info=value if start=NULL Then start=temp Else (a) ptr=start (b)Repeat while ptr->next!=start (i) ptr=ptr->next (c) ptr->next=temp 5. temp->next=start 6. Exit. Insertion after a given node with key ‘K’ 1. 2. 3. 4. 5. If start=NULL Then Print “List is Empty” and Exit. Create a node temp. If temp=NULL Then Print “Overflow” and Exit. ptr=start Repeat while ptr->next!=start and ptr->info!=K (a) ptr=ptr->next 6. If ptr->info=K Then (a) temp->info=value (b) Temp->next=ptr->next (c) Ptr->next=temp Else Print “No node with key ‘K’ exist”

Lecture Notes