Geschreven door studenten die geslaagd zijn Direct beschikbaar na je betaling Online lezen of als PDF Verkeerd document? Gratis ruilen 4,6 TrustPilot
logo-home
Samenvatting

Summary All Lab work

Beoordeling
-
Verkocht
-
Pagina's
4
Geüpload op
14-01-2021
Geschreven in
2020/2021

Summary of 4 pages for the course Data Structures at Comsats Institute Of Information And Technology (All Lab work)

Instelling
Vak

Voorbeeld van de inhoud

1. Singly Linked Lists
The objective of this lab session is to acquire skills in working with singly linked lists. The task is to first
implement the following operations:

1) Create an empty linked list; // do so in the constructor.

2) bool IsEmpty(); // checks whether the list is empty or not. Returns true if empty and false otherwise.

3) InsertAtFront(value); // takes input from a user and inserts it at front of the list

4) Void PrintList();

5) InsertSorted(value); //If we want to maintain a sorted list, we should implement this function

6) Search(value); This function shall search value in a list. If found, we will need to store two addresses:

a. Address of the node in which the searched value is found in a pointer variable named Loc_;
we will store NULL in Loc_ in case value is not found.

b. Address of the node which is logical predecessor of value in a list.

i. The Search() provides functionality for other operations such as insertion in a sorted
list, deleting a value, modifying a value, printing it etc.

7) Delete(value); // searches value and then deletes it if found.

8) DestroyList(); // Distroys all nodes of the list leaving the list in empty state.

Declare Node Class: The data structure that will hold the elements of the list is called Node.
Declare it as follows:
class ListNode{
public:
int data;
ListNode *next;

};

Declare class Linked List:
Now, declare your main class LinkedList. Inside
this class, you shall define all key functions to implement all operations
of a linked list.

class LinkedList{
public:
ListNode *start; // special variable which stores address of head
node.
ListNode *PredLoc_; //to be used by Search(value) method to store
address of logical predecessor of value in a list.
ListNode *Loc_; //to be used by Search(value) method to store address
of the node containing the searched value in a list. If it is not found it
contains NULL.
}

1) Creating a LinkedList
In order to create an empty list, assign NULL value to start pointer
variable.
LinkedList(){
start=NULL;

Geschreven voor

Instelling
Vak

Documentinformatie

Geüpload op
14 januari 2021
Aantal pagina's
4
Geschreven in
2020/2021
Type
SAMENVATTING

Onderwerpen

€7,11
Krijg toegang tot het volledige document:

Verkeerd document? Gratis ruilen Binnen 14 dagen na aankoop en voor het downloaden kun je een ander document kiezen. Je kunt het bedrag gewoon opnieuw besteden.
Geschreven door studenten die geslaagd zijn
Direct beschikbaar na je betaling
Online lezen of als PDF

Maak kennis met de verkoper
Seller avatar
youtubecanvas

Maak kennis met de verkoper

Seller avatar
youtubecanvas COMSATS Institute Of Information Technology
Volgen Je moet ingelogd zijn om studenten of vakken te kunnen volgen
Verkocht
-
Lid sinds
5 jaar
Aantal volgers
0
Documenten
18
Laatst verkocht
-

0,0

0 beoordelingen

5
0
4
0
3
0
2
0
1
0

Recent door jou bekeken

Waarom studenten kiezen voor Stuvia

Gemaakt door medestudenten, geverifieerd door reviews

Kwaliteit die je kunt vertrouwen: geschreven door studenten die slaagden en beoordeeld door anderen die dit document gebruikten.

Niet tevreden? Kies een ander document

Geen zorgen! Je kunt voor hetzelfde geld direct een ander document kiezen dat beter past bij wat je zoekt.

Betaal zoals je wilt, start meteen met leren

Geen abonnement, geen verplichtingen. Betaal zoals je gewend bent via iDeal of creditcard en download je PDF-document meteen.

Student with book image

“Gekocht, gedownload en geslaagd. Zo makkelijk kan het dus zijn.”

Alisha Student

Bezig met je bronvermelding?

Maak nauwkeurige citaten in APA, MLA en Harvard met onze gratis bronnengenerator.

Bezig met je bronvermelding?

Veelgestelde vragen