SlideShare une entreprise Scribd logo
1  sur  33
PRESENTED BY:
AKSHAY WADALKAR
   An array is a collection of elements of similar
    datatype.

   Contiguous memory allocation takes place.

   An array is a DS in which we can access every
    element directly using position variable .

   It is rather an organizational concept.

   Array elements can be accessed individually.

   Syntax: datatype nameofarray [dimension];
 Two types of array-
1. Single dimensional




      single for loop.
2.   Multidimensional




      nesting of for loop.
   Array can be of integer ,character and string.

   Integer and character array can be
    implemented by same logic

   Implementation of string array is quiet
    different from the two.

   We can study the array implementation using
    integer array.
Creation of integer array
                 int
 7   a[0] i=0     a[10]={7,1,32,58,0,5,8,16,9,23}
14   a[1] i=1     ;

32   a[2] i=2    Integer array “a”.
58   a[3] i=3
                    It is of dimension 10 (from 0
 0   a[4] i=4       to 9).
 5   a[5] i=5      Take positing variable i.
 8   a[6] i=6
                   Its storage will be continuous
16   a[7] i=7       20 bytes(2 bytes each).
 9   a[8] i=8
23   a[9] i=9
1.   DECLARATION
     N     SIZE
2.   OPERATION
     Repeat for i= 0 to (size-1)
     arr[i]= num
     end repeat
3.   OUTPUT
     RETURN(arr[i])
 DECLARATION
i   rows
j   coloumn
 OPERATION
    ◦ Repeat for i=0 to (rows-1)
      Repeat for j=0 to (coloumn-1)
        Array[i][j]=num
      End repeat
    ◦ End repeat
   OUTPUT
    Return(Array[i][j])
   No need to declare large number of variables
    individually.

   Variables are not scattered in memory , they
    are stored in contiguous memory.

   Ease the handling of large no of variables of
    same datatype.
   Rigid structure.

   Can be hard to add/remove elements.

   Cannot be dynamically resized in most
    languages.

   Memory loss.
AS A DATA STRUCTURE
   Each element (node) inside a linked list is
    linked to the previous node and successor
    (next) node.
   This allows for more efficient insertion and
    deletion of nodes.



                5     3     14    2




                                             continued
   Each item has a data part (one or more data
    members), and a link that points to the next item.

   One natural way to implement the link is as a
    pointer; that is, the link is the address of the next
    item in the list.

   It makes good sense to view each item as an object,
    that is, as an instance of a class.

   We call that class: Node

   The last item does not point to anything. We set its
    link member to NULL. This is denoted graphically by
    a self-loop
   Insert a new item
    ◦ At the head of the list, or
    ◦ At the tail of the list, or
    ◦ Inside the list, in some designated position
   Search for an item in the list
    ◦ The item can be specified by position, or by some
      value
   Delete an item from the list
    ◦ Search for and locate the item, then remove the
      item, and finally adjust the surrounding pointers
   Suppose you want to find the item whose data
    value is A

   You have to search sequentially starting from the
    head item rightward until the first item whose data
    member is equal to A is found.

   At each item searched, a comparison between the
    data member and A is performed.
LOGIC FOR SEARCHING A LINKED
              LIST

•Since nodes in a linked list have no names, we use two
pointers, pre (for previous) and cur (for current).

•At the beginning of the search, the pre pointer is null and
the cur pointer points to the first node.

•The search algorithm moves the two pointers together
towards the end of the list.
   Declaration
    ◦ Current     0
   Searching
    ◦ for (current = first; current != NULL; current =
      current->next)
    ◦ if (searchItem == current(data))
    ◦ return (current);
    ◦ Break
   Output
    ◦ return (NULL);
Insertion of an Element at the
Head :
  Before the insertion:

       head


                  next              next             next


    element       element           element
           Rome           Seattle          Toronto
Have a new node:

                    head

               next           next             next             next


  element       element       element          element
        Baltimore      Rome          Seattle          Toronto




  Node x = new Node();
  x.setElement(new String(“Baltimore”));
  The following statement is not correct:
  x.element = new String(“Baltimore”));
After the insertion:

     head

                 next          next             next             next


  element        element       element          element
         Baltimore      Rome          Seattle          Toronto




     x.setNext(head);
     head = x;
Deleting an Element at the
Head :
Before the deletion:

     head

                next          next             next             next


  element        element      element          element
         Baltimore     Rome          Seattle          Toronto
Remove the node from the list:

                     head

                next           next             next             next


  element        element       element          element
         Baltimore      Rome          Seattle          Toronto



     head = head.getNext();
After the deletion:

     head

                next             next             next


  element       element          element
         Rome          Seattle          Toronto
Insertion of an Element at the
Tail :
Before the insertion:

     head                                tail


                next              next             next


  element       element           element
         Rome           Seattle          Toronto
Have a new node:

    head                              tail


              next             next             next           next


  element     element          element            element
       Rome          Seattle          Toronto           Baltimore


    Node x = new Node( );
    x.setElement(new String(“Baltimore”));
    x.setNext(null);
    tail.setNext(x);
    tail = x;
After the insertion:

     head                                          tail

                next             next             next           next


   element      element          element      element
         Rome          Seattle          Toronto           Baltimore
Deleting an Element at the
Tail :
Deletion of an element at the tail of a singly linked list takes
more effort.

The difficulty is related with the fact that the last node does not
have a link to the previous node which will become the new
tail of the list.
Before the deletion:

     head                                          tail

                next             next             next           next


  element       element          element      element
         Rome          Seattle          Toronto           Baltimore
Remove the node: How can we find the new tail?

    head                                                tail ?

               next             next             next              next


  element      element          element            element
        Rome          Seattle          Toronto              Baltimore




                                                    should be removed
Singly Linked Lists and Arrays
        Singly linked list                   Array
 Elements are stored in linear   Elements are stored in linear
 order, accessible with links.   order, accessible with an
                                 index.

 Do not have a fixed size.       Have a fixed size.

 Cannot access the previous      Can access the previous
 element directly.               element easily.

 No binary search.               Binary search.
Advantages of linked lists
   Linked lists are dynamic, they can grow or
    shrink as necessary

   Linked lists are non-contiguous; the logical
    sequence of items in the structure is
    decoupled from any physical ordering in
    memory




CS314                   Linked Lists               31
Applications of linked lists

•A linked list is a very efficient data structure for sorted list
that will go through many insertions and deletions.

•A linked list is a dynamic data structure in which the list
can start with no nodes and then grow as new nodes are
needed. A node can be easily deleted without moving other
nodes, as would be the case with an array.

•For example, a linked list could be used to hold the
records of students in a school. Each quarter or semester,
new students enroll in the school and some students leave
or graduate.
Array implementation and linked list as datat structure

Contenu connexe

Tendances

Queue Data Structure
Queue Data StructureQueue Data Structure
Queue Data StructureZidny Nafan
 
Data Structure and its Fundamentals
Data Structure and its FundamentalsData Structure and its Fundamentals
Data Structure and its FundamentalsHitesh Mohapatra
 
linked lists in data structures
linked lists in data structureslinked lists in data structures
linked lists in data structuresDurgaDeviCbit
 
Data Structures (CS8391)
Data Structures (CS8391)Data Structures (CS8391)
Data Structures (CS8391)Elavarasi K
 
Queue Implementation Using Array & Linked List
Queue Implementation Using Array & Linked ListQueue Implementation Using Array & Linked List
Queue Implementation Using Array & Linked ListPTCL
 
Stack and its Applications : Data Structures ADT
Stack and its Applications : Data Structures ADTStack and its Applications : Data Structures ADT
Stack and its Applications : Data Structures ADTSoumen Santra
 
Applications of stack
Applications of stackApplications of stack
Applications of stackeShikshak
 
Double Linked List (Algorithm)
Double Linked List (Algorithm)Double Linked List (Algorithm)
Double Linked List (Algorithm)Huba Akhtar
 

Tendances (20)

linked list
linked list linked list
linked list
 
Stack
StackStack
Stack
 
Abstract data types
Abstract data typesAbstract data types
Abstract data types
 
Queue Data Structure
Queue Data StructureQueue Data Structure
Queue Data Structure
 
Data Structure and its Fundamentals
Data Structure and its FundamentalsData Structure and its Fundamentals
Data Structure and its Fundamentals
 
Expression trees
Expression treesExpression trees
Expression trees
 
Arrays
ArraysArrays
Arrays
 
Abstract Data Types
Abstract Data TypesAbstract Data Types
Abstract Data Types
 
Data structure
Data structureData structure
Data structure
 
linked lists in data structures
linked lists in data structureslinked lists in data structures
linked lists in data structures
 
B and B+ tree
B and B+ treeB and B+ tree
B and B+ tree
 
Data Structures (CS8391)
Data Structures (CS8391)Data Structures (CS8391)
Data Structures (CS8391)
 
Linked list
Linked listLinked list
Linked list
 
Queue Implementation Using Array & Linked List
Queue Implementation Using Array & Linked ListQueue Implementation Using Array & Linked List
Queue Implementation Using Array & Linked List
 
Stack and its Applications : Data Structures ADT
Stack and its Applications : Data Structures ADTStack and its Applications : Data Structures ADT
Stack and its Applications : Data Structures ADT
 
Data Structures
Data StructuresData Structures
Data Structures
 
Applications of stack
Applications of stackApplications of stack
Applications of stack
 
single linked list
single linked listsingle linked list
single linked list
 
Recursion in c++
Recursion in c++Recursion in c++
Recursion in c++
 
Double Linked List (Algorithm)
Double Linked List (Algorithm)Double Linked List (Algorithm)
Double Linked List (Algorithm)
 

En vedette

Searching and Sorting Techniques in Data Structure
Searching and Sorting Techniques in Data StructureSearching and Sorting Techniques in Data Structure
Searching and Sorting Techniques in Data StructureBalwant Gorad
 
Double linked list
Double linked listDouble linked list
Double linked listraviahuja11
 
Individual-In-The-Loop (for Ethically Aligned Artificial Intelligence)
Individual-In-The-Loop (for Ethically Aligned Artificial Intelligence)Individual-In-The-Loop (for Ethically Aligned Artificial Intelligence)
Individual-In-The-Loop (for Ethically Aligned Artificial Intelligence)John C. Havens
 
Insertion and Deletion in Binary Search Trees (using Arrays and Linked Lists)
Insertion and Deletion in Binary Search Trees (using Arrays and Linked Lists)Insertion and Deletion in Binary Search Trees (using Arrays and Linked Lists)
Insertion and Deletion in Binary Search Trees (using Arrays and Linked Lists)Lovelyn Rose
 
6. Linked list - Data Structures using C++ by Varsha Patil
6. Linked list - Data Structures using C++ by Varsha Patil6. Linked list - Data Structures using C++ by Varsha Patil
6. Linked list - Data Structures using C++ by Varsha Patilwidespreadpromotion
 
Data structure using c module 1
Data structure using c module 1Data structure using c module 1
Data structure using c module 1smruti sarangi
 
Linked List, Types of Linked LIst, Various Operations, Applications of Linked...
Linked List, Types of Linked LIst, Various Operations, Applications of Linked...Linked List, Types of Linked LIst, Various Operations, Applications of Linked...
Linked List, Types of Linked LIst, Various Operations, Applications of Linked...Balwant Gorad
 
Trees data structure
Trees data structureTrees data structure
Trees data structureSumit Gupta
 
358 33 powerpoint-slides_8-linked-lists_chapter-8
358 33 powerpoint-slides_8-linked-lists_chapter-8358 33 powerpoint-slides_8-linked-lists_chapter-8
358 33 powerpoint-slides_8-linked-lists_chapter-8sumitbardhan
 
Doubly linked list
Doubly linked listDoubly linked list
Doubly linked listFahd Allebdi
 
Binary Search Tree
Binary Search TreeBinary Search Tree
Binary Search TreeAbhishek L.R
 
Open Legal Data Workshop at Stanford
Open Legal Data Workshop at StanfordOpen Legal Data Workshop at Stanford
Open Legal Data Workshop at StanfordHarry Surden
 
Harry Surden - Artificial Intelligence and Law Overview
Harry Surden - Artificial Intelligence and Law OverviewHarry Surden - Artificial Intelligence and Law Overview
Harry Surden - Artificial Intelligence and Law OverviewHarry Surden
 
AI and Machine Learning Demystified by Carol Smith at Midwest UX 2017
AI and Machine Learning Demystified by Carol Smith at Midwest UX 2017AI and Machine Learning Demystified by Carol Smith at Midwest UX 2017
AI and Machine Learning Demystified by Carol Smith at Midwest UX 2017Carol Smith
 

En vedette (18)

Searching and Sorting Techniques in Data Structure
Searching and Sorting Techniques in Data StructureSearching and Sorting Techniques in Data Structure
Searching and Sorting Techniques in Data Structure
 
Double linked list
Double linked listDouble linked list
Double linked list
 
Individual-In-The-Loop (for Ethically Aligned Artificial Intelligence)
Individual-In-The-Loop (for Ethically Aligned Artificial Intelligence)Individual-In-The-Loop (for Ethically Aligned Artificial Intelligence)
Individual-In-The-Loop (for Ethically Aligned Artificial Intelligence)
 
Insertion and Deletion in Binary Search Trees (using Arrays and Linked Lists)
Insertion and Deletion in Binary Search Trees (using Arrays and Linked Lists)Insertion and Deletion in Binary Search Trees (using Arrays and Linked Lists)
Insertion and Deletion in Binary Search Trees (using Arrays and Linked Lists)
 
Cyber Crime
Cyber CrimeCyber Crime
Cyber Crime
 
Linked list
Linked listLinked list
Linked list
 
6. Linked list - Data Structures using C++ by Varsha Patil
6. Linked list - Data Structures using C++ by Varsha Patil6. Linked list - Data Structures using C++ by Varsha Patil
6. Linked list - Data Structures using C++ by Varsha Patil
 
Data structure using c module 1
Data structure using c module 1Data structure using c module 1
Data structure using c module 1
 
Linked List, Types of Linked LIst, Various Operations, Applications of Linked...
Linked List, Types of Linked LIst, Various Operations, Applications of Linked...Linked List, Types of Linked LIst, Various Operations, Applications of Linked...
Linked List, Types of Linked LIst, Various Operations, Applications of Linked...
 
7 Myths of AI
7 Myths of AI7 Myths of AI
7 Myths of AI
 
linked list
linked list linked list
linked list
 
Trees data structure
Trees data structureTrees data structure
Trees data structure
 
358 33 powerpoint-slides_8-linked-lists_chapter-8
358 33 powerpoint-slides_8-linked-lists_chapter-8358 33 powerpoint-slides_8-linked-lists_chapter-8
358 33 powerpoint-slides_8-linked-lists_chapter-8
 
Doubly linked list
Doubly linked listDoubly linked list
Doubly linked list
 
Binary Search Tree
Binary Search TreeBinary Search Tree
Binary Search Tree
 
Open Legal Data Workshop at Stanford
Open Legal Data Workshop at StanfordOpen Legal Data Workshop at Stanford
Open Legal Data Workshop at Stanford
 
Harry Surden - Artificial Intelligence and Law Overview
Harry Surden - Artificial Intelligence and Law OverviewHarry Surden - Artificial Intelligence and Law Overview
Harry Surden - Artificial Intelligence and Law Overview
 
AI and Machine Learning Demystified by Carol Smith at Midwest UX 2017
AI and Machine Learning Demystified by Carol Smith at Midwest UX 2017AI and Machine Learning Demystified by Carol Smith at Midwest UX 2017
AI and Machine Learning Demystified by Carol Smith at Midwest UX 2017
 

Similaire à Array implementation and linked list as datat structure

singly link list project in dsa.....by rohit malav
singly link list project in dsa.....by rohit malavsingly link list project in dsa.....by rohit malav
singly link list project in dsa.....by rohit malavRohit malav
 
03_LinkedLists_091.ppt
03_LinkedLists_091.ppt03_LinkedLists_091.ppt
03_LinkedLists_091.pptsoniya555961
 
Fundamentals of data structures
Fundamentals of data structuresFundamentals of data structures
Fundamentals of data structuresNiraj Agarwal
 
Sorting & Linked Lists
Sorting & Linked ListsSorting & Linked Lists
Sorting & Linked ListsJ.T.A.JONES
 
Bsc cs ii dfs u-2 linklist,stack,queue
Bsc cs ii  dfs u-2 linklist,stack,queueBsc cs ii  dfs u-2 linklist,stack,queue
Bsc cs ii dfs u-2 linklist,stack,queueRai University
 
Funddamentals of data structures
Funddamentals of data structuresFunddamentals of data structures
Funddamentals of data structuresGlobalidiots
 
Bca ii dfs u-2 linklist,stack,queue
Bca ii  dfs u-2 linklist,stack,queueBca ii  dfs u-2 linklist,stack,queue
Bca ii dfs u-2 linklist,stack,queueRai University
 
Mca ii dfs u-3 linklist,stack,queue
Mca ii dfs u-3 linklist,stack,queueMca ii dfs u-3 linklist,stack,queue
Mca ii dfs u-3 linklist,stack,queueRai University
 
1 list datastructures
1 list datastructures1 list datastructures
1 list datastructuresNguync91368
 
DS Complete notes for Computer science and Engineering
DS Complete notes for Computer science and EngineeringDS Complete notes for Computer science and Engineering
DS Complete notes for Computer science and EngineeringRAJASEKHARV8
 

Similaire à Array implementation and linked list as datat structure (20)

Unit i(dsc++)
Unit i(dsc++)Unit i(dsc++)
Unit i(dsc++)
 
singly link list project in dsa.....by rohit malav
singly link list project in dsa.....by rohit malavsingly link list project in dsa.....by rohit malav
singly link list project in dsa.....by rohit malav
 
03_LinkedLists_091.ppt
03_LinkedLists_091.ppt03_LinkedLists_091.ppt
03_LinkedLists_091.ppt
 
1.ppt
1.ppt1.ppt
1.ppt
 
Fundamentals of data structures
Fundamentals of data structuresFundamentals of data structures
Fundamentals of data structures
 
Sorting & Linked Lists
Sorting & Linked ListsSorting & Linked Lists
Sorting & Linked Lists
 
Chapter 5 ds
Chapter 5 dsChapter 5 ds
Chapter 5 ds
 
Lec3
Lec3Lec3
Lec3
 
Bsc cs ii dfs u-2 linklist,stack,queue
Bsc cs ii  dfs u-2 linklist,stack,queueBsc cs ii  dfs u-2 linklist,stack,queue
Bsc cs ii dfs u-2 linklist,stack,queue
 
Linked list1.ppt
Linked list1.pptLinked list1.ppt
Linked list1.ppt
 
Funddamentals of data structures
Funddamentals of data structuresFunddamentals of data structures
Funddamentals of data structures
 
Lec3
Lec3Lec3
Lec3
 
Bca ii dfs u-2 linklist,stack,queue
Bca ii  dfs u-2 linklist,stack,queueBca ii  dfs u-2 linklist,stack,queue
Bca ii dfs u-2 linklist,stack,queue
 
Data structures
Data structuresData structures
Data structures
 
Mca ii dfs u-3 linklist,stack,queue
Mca ii dfs u-3 linklist,stack,queueMca ii dfs u-3 linklist,stack,queue
Mca ii dfs u-3 linklist,stack,queue
 
1 list datastructures
1 list datastructures1 list datastructures
1 list datastructures
 
Lect-1.pptx
Lect-1.pptxLect-1.pptx
Lect-1.pptx
 
Data structures
Data structuresData structures
Data structures
 
intr_ds.ppt
intr_ds.pptintr_ds.ppt
intr_ds.ppt
 
DS Complete notes for Computer science and Engineering
DS Complete notes for Computer science and EngineeringDS Complete notes for Computer science and Engineering
DS Complete notes for Computer science and Engineering
 

Plus de Tushar Aneyrao

Varaiational formulation fem
Varaiational formulation fem Varaiational formulation fem
Varaiational formulation fem Tushar Aneyrao
 
General purpose simulation System (GPSS)
General purpose simulation System (GPSS)General purpose simulation System (GPSS)
General purpose simulation System (GPSS)Tushar Aneyrao
 
Presentation on robotics
Presentation on roboticsPresentation on robotics
Presentation on roboticsTushar Aneyrao
 
Seminar o nm aterial enginering
Seminar o nm aterial engineringSeminar o nm aterial enginering
Seminar o nm aterial engineringTushar Aneyrao
 

Plus de Tushar Aneyrao (7)

Varaiational formulation fem
Varaiational formulation fem Varaiational formulation fem
Varaiational formulation fem
 
General purpose simulation System (GPSS)
General purpose simulation System (GPSS)General purpose simulation System (GPSS)
General purpose simulation System (GPSS)
 
Safety of vehicles
Safety of vehiclesSafety of vehicles
Safety of vehicles
 
Seminar on cim 02
Seminar on cim 02Seminar on cim 02
Seminar on cim 02
 
Presentation on robotics
Presentation on roboticsPresentation on robotics
Presentation on robotics
 
Seminar o nm aterial enginering
Seminar o nm aterial engineringSeminar o nm aterial enginering
Seminar o nm aterial enginering
 
Seminar on fatigue
Seminar on fatigueSeminar on fatigue
Seminar on fatigue
 

Dernier

"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...Zilliz
 
Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Zilliz
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamUiPathCommunity
 
WSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2
 
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelMcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelDeepika Singh
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistandanishmna97
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...apidays
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...apidays
 
Platformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityPlatformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityWSO2
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDropbox
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Zilliz
 
Vector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxVector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxRemote DBA Services
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdfSandro Moreira
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businesspanagenda
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWERMadyBayot
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024The Digital Insurer
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoffsammart93
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...DianaGray10
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxRustici Software
 

Dernier (20)

"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
 
WSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering Developers
 
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelMcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistan
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
Platformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityPlatformless Horizons for Digital Adaptability
Platformless Horizons for Digital Adaptability
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
 
Vector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxVector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptx
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 

Array implementation and linked list as datat structure

  • 2. An array is a collection of elements of similar datatype.  Contiguous memory allocation takes place.  An array is a DS in which we can access every element directly using position variable .  It is rather an organizational concept.  Array elements can be accessed individually.  Syntax: datatype nameofarray [dimension];
  • 3.  Two types of array- 1. Single dimensional single for loop. 2. Multidimensional nesting of for loop.
  • 4. Array can be of integer ,character and string.  Integer and character array can be implemented by same logic  Implementation of string array is quiet different from the two.  We can study the array implementation using integer array.
  • 5. Creation of integer array  int 7 a[0] i=0 a[10]={7,1,32,58,0,5,8,16,9,23} 14 a[1] i=1 ; 32 a[2] i=2  Integer array “a”. 58 a[3] i=3  It is of dimension 10 (from 0 0 a[4] i=4 to 9). 5 a[5] i=5  Take positing variable i. 8 a[6] i=6  Its storage will be continuous 16 a[7] i=7 20 bytes(2 bytes each). 9 a[8] i=8 23 a[9] i=9
  • 6. 1. DECLARATION N SIZE 2. OPERATION Repeat for i= 0 to (size-1) arr[i]= num end repeat 3. OUTPUT RETURN(arr[i])
  • 7.  DECLARATION i rows j coloumn  OPERATION ◦ Repeat for i=0 to (rows-1)  Repeat for j=0 to (coloumn-1)  Array[i][j]=num  End repeat ◦ End repeat  OUTPUT Return(Array[i][j])
  • 8. No need to declare large number of variables individually.  Variables are not scattered in memory , they are stored in contiguous memory.  Ease the handling of large no of variables of same datatype.
  • 9. Rigid structure.  Can be hard to add/remove elements.  Cannot be dynamically resized in most languages.  Memory loss.
  • 10. AS A DATA STRUCTURE
  • 11. Each element (node) inside a linked list is linked to the previous node and successor (next) node.  This allows for more efficient insertion and deletion of nodes. 5 3 14 2 continued
  • 12. Each item has a data part (one or more data members), and a link that points to the next item.  One natural way to implement the link is as a pointer; that is, the link is the address of the next item in the list.  It makes good sense to view each item as an object, that is, as an instance of a class.  We call that class: Node  The last item does not point to anything. We set its link member to NULL. This is denoted graphically by a self-loop
  • 13. Insert a new item ◦ At the head of the list, or ◦ At the tail of the list, or ◦ Inside the list, in some designated position  Search for an item in the list ◦ The item can be specified by position, or by some value  Delete an item from the list ◦ Search for and locate the item, then remove the item, and finally adjust the surrounding pointers
  • 14. Suppose you want to find the item whose data value is A  You have to search sequentially starting from the head item rightward until the first item whose data member is equal to A is found.  At each item searched, a comparison between the data member and A is performed.
  • 15. LOGIC FOR SEARCHING A LINKED LIST •Since nodes in a linked list have no names, we use two pointers, pre (for previous) and cur (for current). •At the beginning of the search, the pre pointer is null and the cur pointer points to the first node. •The search algorithm moves the two pointers together towards the end of the list.
  • 16. Declaration ◦ Current 0  Searching ◦ for (current = first; current != NULL; current = current->next) ◦ if (searchItem == current(data)) ◦ return (current); ◦ Break  Output ◦ return (NULL);
  • 17.
  • 18. Insertion of an Element at the Head : Before the insertion: head next next next element element element Rome Seattle Toronto
  • 19. Have a new node: head next next next next element element element element Baltimore Rome Seattle Toronto Node x = new Node(); x.setElement(new String(“Baltimore”)); The following statement is not correct: x.element = new String(“Baltimore”));
  • 20. After the insertion: head next next next next element element element element Baltimore Rome Seattle Toronto x.setNext(head); head = x;
  • 21. Deleting an Element at the Head : Before the deletion: head next next next next element element element element Baltimore Rome Seattle Toronto
  • 22. Remove the node from the list: head next next next next element element element element Baltimore Rome Seattle Toronto head = head.getNext();
  • 23. After the deletion: head next next next element element element Rome Seattle Toronto
  • 24. Insertion of an Element at the Tail : Before the insertion: head tail next next next element element element Rome Seattle Toronto
  • 25. Have a new node: head tail next next next next element element element element Rome Seattle Toronto Baltimore Node x = new Node( ); x.setElement(new String(“Baltimore”)); x.setNext(null); tail.setNext(x); tail = x;
  • 26. After the insertion: head tail next next next next element element element element Rome Seattle Toronto Baltimore
  • 27. Deleting an Element at the Tail : Deletion of an element at the tail of a singly linked list takes more effort. The difficulty is related with the fact that the last node does not have a link to the previous node which will become the new tail of the list.
  • 28. Before the deletion: head tail next next next next element element element element Rome Seattle Toronto Baltimore
  • 29. Remove the node: How can we find the new tail? head tail ? next next next next element element element element Rome Seattle Toronto Baltimore should be removed
  • 30. Singly Linked Lists and Arrays Singly linked list Array Elements are stored in linear Elements are stored in linear order, accessible with links. order, accessible with an index. Do not have a fixed size. Have a fixed size. Cannot access the previous Can access the previous element directly. element easily. No binary search. Binary search.
  • 31. Advantages of linked lists  Linked lists are dynamic, they can grow or shrink as necessary  Linked lists are non-contiguous; the logical sequence of items in the structure is decoupled from any physical ordering in memory CS314 Linked Lists 31
  • 32. Applications of linked lists •A linked list is a very efficient data structure for sorted list that will go through many insertions and deletions. •A linked list is a dynamic data structure in which the list can start with no nodes and then grow as new nodes are needed. A node can be easily deleted without moving other nodes, as would be the case with an array. •For example, a linked list could be used to hold the records of students in a school. Each quarter or semester, new students enroll in the school and some students leave or graduate.