Posts

Showing posts from April, 2021

DS - Traversing Linear Array.

Traversing Linear Array. Accessing each record exactly once. Traversing is a simplpe process which is helpfull to print each record/element of data structure. From the below algorithm we can understand the logic of traversing of linear array. Algorithm for traversing Linear Array. Repeat for i=LB to UB. apply PROCESS to LA[i] [end of for loop] Exit. From the above algorithm it is very easy to understand the logic of traversing in stepwise manner. As we can see in the first step we have described the logic of for loop where loop will visit each element of array from first position till the last location. After the loop statement we have used preocess(for ex., printf) which will access and display each array element of LA i.e., linear array. Loop will end here. Finally Exit which shows completion. On the basis of same algorithm we can create program as per our requirement.

DS - Linked List

LINKED LIST Representation of linked list in memory. Traversing a linked list. Searching a linked list. Linked list is most advanced data structure than array. It is different than array because in array there was sequential memory locations allocated and here in linked list memory locations are not in sequence i.e., in linked list data elements are saved at any locations randomly. All the elements are linked to each other. The linking is done with the help of pointer (ptr) . It is very important to know the start of linked list because it is not like array where we can find linked list location easily. That’s why in linked list start pointer is used which stores the locations of first element of linked list. In each node of linked list there are two parts are available. The first part is known as data which contains elements and in other part the address/location of next element is stored. That’s why this part is known as next part . Where the linked list ends at that l...

DS - Searching a Linked List

Searching a Linked List Seaarching in a linked list is very basic data structure operation. Here in a linked list, it is little time consuming task, as like linear search in array. Here in linked list we have to compair the elememnt with each & every element of linked list. From the below algorithm we will try to understand how search operation takes place in linked list. Algorithm for searching a linked list. As we can see in above algorithm the searching operation is expalined in easy manner in step by step pattern. In the first step ptr is started from starting location of linked list, then while loop will go through all the elements of linked list till null pointer. Now we have to compair item with each and every element of INFO linked list. If element founds the searc operation becomes successfull otherwise unsuccessfull. However counter must goes continuously with the help of link ptr.

DS - Representation of linked list in memory.

Image
Representation of linked list in memory. Linked list is more advanced as compared to array. But there are many differences such as there is no sequential memory allocation and other major difference is that there is a use of pointers i.e., link . Linked lisst is represented in the below diagram. As we can see in the above diagram, it is a linked list which contain elements, which are linked to each other with the help of pointers. Pointera are used to link previous and next element. All these elements are stored at different and random locations. Thats why it is very important to know the start of linked list. For this purpose start ptr is used, which points to the first element/ starting element of the linked list.

Data Structure - Traversing a linked list

Traversing a linked list Traversing is nothing but, accessing each record exactly once. In simple manner we can say that traversing is nothing but visiting or accessing each record of data structure. ALGORITHM FOR TRAVERSING A LINKED LIST As we can see in above algorithm the traversing of linked list is properly described in easy manner. In the first step of algorithm we have set pointer to the start location. Here we have to use while loop, which will goes continue till null pointer reached. Now we have to access each and every element/node of linked list named INFO to increase the counter we are putting link of next element into the ptr. So that the loop will go to next position. In this way each & every element of linked list will be accessed & final step is Exit.

Data Structure - Traversing a linked list algorithm

Traversing a linked list Algorithm Set ptr:=start Repeat while ptr!=null.(ptr is not equal to null.) Apply PROCESS to INFO[ptr] Set ptr:=Link[ptr] [end of loop] Exit.

Data Structure - Searching a linked list algorithm

Searching a linked list Algorithm Set ptr:=start Repeat while ptr!=null.(ptr is not equal to null.) if item=INFO[ptr], then print "Found" [end of if structure.] Set ptr:=link[ptr]. [end of loop] [Search unsuccessful] print "Not found" Exit. Algorithm for traversing a linked list.

Logical reasoning Quiz on Alphabet series

Image