logo

Data Structure - Assignment

9 Pages1398 Words163 Views
   

Added on  2021-04-17

Data Structure - Assignment

   Added on 2021-04-17

ShareRelated Documents
Running head: DATA STRUCTURESELECTED TOPIC: EXPLAIN HOW TO INSERT AND REMOVE ITEMS FROM ALINKED LISTName of StudentName of UniversityAuthor note
Data Structure - Assignment_1
1DATA STRUCTUREData nextData NullData Next nexnextnextaddres adaddressData nextList abstract data typeAn abstract data type is a data type whose implementation is kept hidden from the front-end user while it is used in operations. In data structures abstraction is widely used and one ofthem is list abstract data type (List ADT). These lists can be referenced as containers of data’swhich keeps data abstracted to the end users and deals with data structures (Lafore 2017). Thebest example of list abstract data type is linked list.Storage of the list values in a linked listIn linked list, one need to create a structure which has memory allocation for data andlinks, each of this structure is called as node. This links are used as pointers which points to thenext node. These linked nodes as a whole is called a linked list (Lam 2015). In order to insert a data in the linked list, one need to create a node, link the last node ofthe current list with this new node and terminate the link part of the last node to null. In thisprocess the linked list stores the list values. In the process of storing data’s in linked list, one mayhave to traverse the entire list (Mehlhorn 2013).
Data Structure - Assignment_2
2DATA STRUCTUREInsertion and removal of data at the starting nodeIn order to insert a data at the start of the linked list, one needs to add the node containingthe specified data at the very beginning of the linked list. Firstly, the existence the current linkedlist is checked by checking the value of the head node, if the head node is null then the linked listis empty and by creating the temp node the very first node of the of the list is created. In case the head node already exists the new or temp node’s data part contains the data to beadded, and the link of the temp node contains the address of the head node or the first node thecurrent linked list. In this data’s at the starting of a linked list is added. Following code explainsthis in details:CODE:voidadd_element(struct node **hd){intnum;struct node *t1 = NULL, *t2 = NULL;printf("Enter the element to be added: ");scanf("%d", &num);if(*hd == NULL){*hd = (struct node *)malloc(sizeof(struct node));
Data Structure - Assignment_3

End of preview

Want to access all the pages? Upload your documents or become a member.

Related Documents
Implementation of Linked List
|5
|1119
|220

Interview Questions
|7
|1175
|91

Implementing Linked List in C++: Efficient Data Structure for Storing and Manipulating Elements
|3
|282
|146

Write a program that reads data about people from a file.
|2
|429
|373

How to Create a Test File in C++ PDF
|8
|1260
|40

Data Structures and Algorithms: Linked List Implementation for Student Records
|2
|862
|210