Professional Documents
Culture Documents
Data Structures Assignment #3 Vinay Ratnapu 110-00-1127 1) Write An Algorithm or Code Segment For Searching A Circular Linked List For A Given Item
Data Structures Assignment #3 Vinay Ratnapu 110-00-1127 1) Write An Algorithm or Code Segment For Searching A Circular Linked List For A Given Item
ASSIGNMENT #3
Vinay Ratnapu
110-00-1127
The logical and mathematical model of a particular organization of data is called Data
Contains component data items which may be atomic or another data structure
Defines rules as to how components relate to each other and to the structure as a whole
consideration:
It must be rich enough in structure to mirror actual relationships of data in real world for
example the hierarchical relationship of the entities is best described by the “tree” data
structure.
The structure should be simple enough that one can effectively process the data when
necessary.
Circular Linked List- A circular linked list is a linked list in which last element or node
of the list points to first node. For non-empty circular linked list, there are no NULL
pointers. The memory declarations for representing the circular linked lists are the same
as for linear linked lists. All operations performed on linear linked lists can be easily
While inserting new node at the end of the list, its next pointer field is made to point to
While testing for end of list, we compare the next pointer field with address of the first
list. Header linked list is a linked list which always contains a special node called the
header node, at the beginning of the list. This header node usually contains vital
information about the linked list such as number of nodes in lists, whether list is sorted
or not etc. Circular header lists are frequently used instead of ordinary linked lists as
many operations are much easier to state and implement using header lists
This comes from the following two properties of circular header linked lists:
The null pointer is not used, and hence all pointers contain valid addresses
Every (ordinary ) node has a predecessor, so the first node may not require a special case.
Set PTR:=LINK[PTR]
[End of Loop]
Step 3: Return
Searching a circular header linked list
Algorithm: SRCHHL(INFO,LINK,START,ITEM,LOC)
Set PTR:=LINK[PTR]
[End of Loop]
Set LOC:=PTR
Else:
Set LOC:=NULL
[End of If structure]
Step 4: Return
an item in a circular linked list (the nth item that follows the given item
in the list).
This algorithm inserts in a circular linked list after the kth node
Write: ‘OVERFLOW’
Return
Step 2: Set NEW:=AVAIL and AVAIL:=LINK[AVAIL]
Set INFO[NEW]:=ITEM
Set LINK[NEW]:=LINK[PTR]
Set LINK[PTR]:=NEW
Return
[End of if structure]
Set LINK[PTR]:=NEW
Step 8: Return
Binary Tree- A binary tree T is defined as a finite set of elements, called nodes, such
that either:
Two trees T1 and T2 are called respectively left and right subtree of R (root node of T). If
B C
D E G H
F J K
Set TOP:=TOP + 1
[End of If structure]
Else:
Set PTR:=STACK[TOP]
Set TOP:=TOP-1
[End of If structure]
Step 6: Return
algorithm.
some specified condition has been satisfied. The process is used for repetitive
computations in which each action is stated in terms of the previous result. Many
iterative (or repetitive) problems can be written in this form. In order to solve a problem
#include <iostream>
#include <conio.h>
--counter;
if (counter < 0)
return -1;
if (array[counter] == 10)
return (counter+1);
else
return linearSearch(array,counter);