SlideShare uma empresa Scribd logo
1 de 10
ARRAY
an array data structure or simply an array is a data structure consisting of a collection
of elements (values orvariables), each identified by at least one array index or key.
Applications
Arrays are used to implement mathematical vectors and matrices, as well as other kinds of
rectangular tables.

One-dimensional arrays
A one-dimensional array (or single dimension array) is a type of linear array. Accessing its
elements involves a single subscript which can either represent a row or column index.
As an example consider the C declaration int anArrayName[10];

Multidimensional arrays
For a two-dimensional array, the element with indices i,j would have address B + c · i + d · j,
where the coefficients c and d are the rowand column address increments, respectively.
For example: int a[3][2];
STACK::
A stack is a list in which insertion and deletion take place at the same end
This end is called top
The other end is called bottom
Stacks are known as LIFO (Last In, First Out) lists.
The last element inserted will be the first to be retrieved
Primary operations: Push and Pop
Push
Add an element to the top of the stack
Pop
Remove the element at the top of the stack

Implementation of Stacks
Any list implementation could be used to implement a stack
Arrays (static: the size of stack is given initially)
Linked lists (dynamic: never become full)

CODE)CHECK IT
LB=O;
TOP=LB;                                           INSEERTION
WHILE TOP!= 4
READ X
NUM[TOP]=X
TOP=TOP+1

TOP=TOP-1
WHILE TOP!= -1                                    DELETION
            {TOP= TOP -1}

QEUEE
Like a stack, a queue is also a list. However, with a queue, insertion is done at one end, while
deletion is performed at the other end.
Accessing the elements of queues follows a First In, First Out (FIFO) order.
Like customers standing in a check-out line in a store, the first customer in is the first customer
served.
Enqueue and Dequeue
Primary queue operations: Enqueue and Dequeue
Like check-out lines in a store, a queue has a front and a rear.
Enqueue – insert an element at the rear of the queue
Dequeue – remove an element from the front of the queue


Implementation of Queue

Just as stacks can be implemented as arrays or linked lists, so with queues.
Dynamic queues have the same advantages over static queues as dynamic stacks have over static
stacks

Queue Implementation of Array
There are several different algorithms to implement Enqueue and Dequeue
Naïve way
When enqueuing, the front index is always fixed and the rear index moves forward in the array.

 rear                                         rear                                        rear



   3                                    3       6                            3       6       9


 front                               front                                front
  Enqueue(3)                           Enqueue(6)                           Enqueue(9)


Naïve way (cont’d)
When dequeuing, the front index is fixed, and the element at the front the queue is removed.
Move all the elements after it by one position. (Inefficient!!!)
rear                       rear                                     rear = -1



   6        9                           9


 front                               front                                   front
   Dequeue()                             Dequeue()                             Dequeue()
Delete ( ):
Description: Here QUEUE is an array with N locations. FRONT and REAR points to the front
and rear of
the QUEUE.
1. If (FRONT == 0) Then [Check for underflow]
2. Print: Underflow
3. Else
4. ITEM = QUEUE[FRONT]
5. If (FRONT == REAR) Then [Check if only one element is left]
(a) Set FRONT = 0
(b) Set REAR = 0
6. Else
7. Set FRONT = FRONT + 1 [Increment FRONT by 1]
[End of Step 5 If]
8. Print: ITEM deleted
[End of

Insert ( ):
Description: Here QUEUE is an array with N locations. FRONT and REAR points to the front
and rear of
the QUEUE. ITEM is the value to be inserted.
1. If (REAR == N) Then [Check for overflow]
2. Print: Overflow
3. Else
4. If (FRONT and REAR == 0) Then [Check if QUEUE is empty]
(a) Set FRONT = 1
(b) Set REAR = 1
5. Else
6. Set REAR = REAR + 1 [Increment REAR by 1]
[End of Step 4 If]
7. QUEUE[REAR] = ITEM
8. Print: ITEM inserted
[End of Step 1 If]
9. Exit
LINKLIST
  A linked list or one way list is a linear collection of data elements called nodes where the linear
order is given by means of pointers. That is each node is divided into two parts the first part
contains the address of the element and the second part called the link field or next pointer field
contains the address of the next node in the list.

The linked list can be of following types:

1. Linear Linked List or One Way List or Singly Linked List.
2. Doubly Linked List or Two Way List.
3. Circular Linked List.
4. Header Linked List.
5. Two Way Header Linked List.
6. Circular Header Linked List.
7. Two Way Circular Header Linked List

      •      Types of linked lists:
                – Singly linked list
                          • Begins with a pointer to the first node
                          • Terminates with a null pointer
                          • Only traversed in one direction
                – Circular, singly linked
                          • Pointer in the last node points back to the first node
                – Doubly linked list
                          • Two “start pointers” – first element and last element
                          • Each node has a forward pointer and a backward pointer
                          • Allows traversals both forwards and backwards
                – Circular, doubly linked list
                          • Forward pointer of the last node points to the first node and backward
                              pointer of the first node points to the last node
Header Linked List.
Header Linked List: A header linked list which always contains a special node, called the header node, at
the beginning of the list. The following are two kinds of widely used header list:
 1.          A grounded header list is a header list where the last node contains the null pointer.
 2.          A circular header list is a header list where the last node points back to the header node.
          Unless otherwise stated or implied, our header list will always be circular list. Accordingly, in
          such a case, the header node also acts as a sentinel indicating the end of the list.




Header Linked List


. Two Way Header Linked List.
The two-way list is a linear collection of data elements called nodes where each node is divided into three
parts:
 1.          An information field INFO which contains the data of N
 2.          A pointer field FORW which contains the location of the next node in the list.
 3.          A pointer field BACK which contains the location of the preceding node in the list.
The list also requires two list pointer variables: FIRST, which points to the first node in the list, and LAST,
which points to the last node in the list. Observe that the null pointer appears in the FORW field of the last
node in the list and also in the BACK field




of the first node in the list.


TREE (inorder, preorder, postfix, memory representation by
array and link list)

     •    Tree nodes contain two or more links
               –     All other data structures we have discussed only contain one


     •    Binary trees


               –     All nodes contain two links


                          •      None, one, or both of which may be NULL


               –     The root node is the first node in a tree.


               –     Each link in the root node refers to a child


               –     A node with no children is called a leaf node


     •    Binary search tree


               –     Values in left sub tree less than parent


               –     Values in right sub tree greater than parent


               –     Facilitates duplicate elimination


               –     Fast searches - for a balanced tree, maximum of log n comparisons
4
                                      7

                 2                                         7
                 5                                         7
 1                       4                     6                       93
 1                       3                     5
7 17                    3 44                       6
                        1                          8
    •   Tree traversals:
            – In order traversal – prints the node values in ascending order
1. Traverse the left sub tree with an in order traversal
2. Process the value in the node (i.e., print the node value)
3. Traverse the right sub tree with an in order traversal
            – Preorder traversal
1. Process the value in the node
2. Traverse the left sub tree with a preorder traversal
3. Traverse the right sub tree with a preorder traversal
            – Post order traversal
1. Traverse the left subtree with a postorder traversal
2. Traverse the right subtree with a postorder traversal
3. Process the value in the node
For example




can be represented by the array



Suppose we would like to represent the following tree in memory, using only lists (which are
created by chaining conses). You should already know how acons is created and what parts
constitute one. If not, go back to an introductory book on Common Lisp.
This tree can be represented as a set of linked lists, like in the following diagram:




The natural way to represent the previous tree as a Common Lisp list is like the following:



(1 (2 6 7 8) 3 (4 (9 12)) (5 10 11))

The first element of a list is the root of that tree (or a node) and the rest of the elements are
the subtrees (more nodes). For example, the subtree (2 6 7 8)is a tree with “2” at its root
and the elements “6 7 8” as its children.



Graph definition
A graph is a collection of nodes called vertices, and the connections between them, called edges.
An example
The following diagram shows a graph with 5 vertices and 7 edges. The edges between A and D
and B and C are pairs that make a bidirectional connection, represented here by a double-headed
arrow.
disjkstra algorithm to find shortest path
 The indented lines under a given line are done under the condition that line. Once that condition
is no longer met you move on in the algorithm. The first part of the algorithm is an initialization
of the graph into the setup described earlier; the rest is concerned with searching through the
graph to find distances. To illustrate the algorithm we provide an example below.




In the above picture o is marked by a double circle. The Unburned node with the smallest &delta
value is orange. It will be burned at the next step in the algorithm. The yellow vertex is the one
that is currently burning. Gray vertices have been labeled as Burned by the algorithm. Neighbors
if the burning vertex whose &delta is being updated have their edges marked in orange. This
happens when δ(u) + w(u,n) < &delta(n). Edges corresponding to sources are marked in blue.
Note that the algorithm will occasionally overwrite the source of a vertex with a closer source.
Once all the vertices are Burned the algorithm is burned.
Now that we've run the algorithm how do we find the shortest path from o to another vertex? We
simply follow thesource edges (blue in the example) from the destination until we reach o, and
the distance we have travelled corresponds to the label &delta on the destination. We also know
that we have actually found the shortest path (it is possible to have more than one path tied for
being the shortest) since our fire has always chosen to take the shortest steps possible when
moving to a new location.
You might have already noticed that the blue subgraph doesn't contain any loops, and this is what
mathematicians call a tree. In fact this is a very special kind of tree called a minimal spanning
tree because it grows from the root o to all of its leaves, the other vertices in G, in the shortest
way possible. Minimal spanning trees are very useful. For instance, if a cable company needs to
wire all the houses in a neighborhood using as little wire as possible, a minimal spanning tree of
the neighborhood provides them with the most efficient way to do so.
Game tree (definiton)
games) game tree - A tree representing contingencies in a game. Each node in a game tree
       represents a possible position (e.g., possible configuration of pieces on a chessboard) in
       the game, and each branching ("edge" in graph terms) represents a possible move.
A constructor gets called automatically when you create an object of a class; if you define your
own constructor, by default a constructor is called which is the Default Constructor. A class can
have more than one constructor. It has the same name as the class itself.

Destructors are again methods of a class that enable the destruction of an object after its use;
destructors also provide the means of memory clean up after usage. Destructors are always called
in the reverse order of Constructors. There can only be one destructor per class and they neither
take an input parameter nor do they return anything. Destructors need not be called explicitly.

Code:
class Vehicle
{
  Int Registration = 0;
  public:
  Vehicle(int regis) // constructor
  {
    Registration = regis;
  }
  Virtual void GetRegistration() = 0;
  ~Vehicle() // destructor
     {
     }

ATTRIBUTE FUNCTION
        In GNU C, you declare certain things about functions called in your
program which help the compiler optimize function calls and check your
code more carefully.

   The keyword `__attribute__' allows you to specify special attributes
when making a declaration. This keyword is followed by an attribute
specification inside double parentheses.
  void fatal () __attribute__ ((noreturn));

             void
             fatal (...)
             {
               ... /* Print error message. */ ...
               exit (1);
             }



Attribute Member
  The member attribute is a multi-value attribute that contains the list of distinguished names for the
  user, group, and contact objects that are members of the group. Each item in the list is a linked
reference to the object that represents the member; therefore, the Active Directory server automatically
updates the distinguished names in the member property when a member object is moved or renamed.

Mais conteúdo relacionado

Mais procurados

Array implementation and linked list as datat structure
Array implementation and linked list as datat structureArray implementation and linked list as datat structure
Array implementation and linked list as datat structureTushar Aneyrao
 
Lecture 13 data structures and algorithms
Lecture 13 data structures and algorithmsLecture 13 data structures and algorithms
Lecture 13 data structures and algorithmsAakash deep Singhal
 
Loop Like a Functional Programing Native
Loop Like a Functional Programing NativeLoop Like a Functional Programing Native
Loop Like a Functional Programing NativeJiaming Zhang
 
Purely Functional Data Structures in Scala
Purely Functional Data Structures in ScalaPurely Functional Data Structures in Scala
Purely Functional Data Structures in ScalaVladimir Kostyukov
 
Data structure , stack , queue
Data structure , stack , queueData structure , stack , queue
Data structure , stack , queueRajkiran Nadar
 
Data structures in scala
Data structures in scalaData structures in scala
Data structures in scalaMeetu Maltiar
 
Lecture 4 data structures and algorithms
Lecture 4 data structures and algorithmsLecture 4 data structures and algorithms
Lecture 4 data structures and algorithmsAakash deep Singhal
 
Linked list
Linked listLinked list
Linked listVONI
 
Data Structure (Dynamic Array and Linked List)
Data Structure (Dynamic Array and Linked List)Data Structure (Dynamic Array and Linked List)
Data Structure (Dynamic Array and Linked List)Adam Mukharil Bachtiar
 
Binary Search Tree
Binary Search TreeBinary Search Tree
Binary Search Treesagar yadav
 
Data Structures in Python
Data Structures in PythonData Structures in Python
Data Structures in PythonDevashish Kumar
 
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
 
Data structure lecture 5
Data structure lecture 5Data structure lecture 5
Data structure lecture 5Kumar
 
Data Structures - Lecture 7 [Linked List]
Data Structures - Lecture 7 [Linked List]Data Structures - Lecture 7 [Linked List]
Data Structures - Lecture 7 [Linked List]Muhammad Hammad Waseem
 
Class 9: Consistent Hashing
Class 9: Consistent HashingClass 9: Consistent Hashing
Class 9: Consistent HashingDavid Evans
 

Mais procurados (20)

Array implementation and linked list as datat structure
Array implementation and linked list as datat structureArray implementation and linked list as datat structure
Array implementation and linked list as datat structure
 
Lecture 13 data structures and algorithms
Lecture 13 data structures and algorithmsLecture 13 data structures and algorithms
Lecture 13 data structures and algorithms
 
Avl tree
Avl treeAvl tree
Avl tree
 
Loop Like a Functional Programing Native
Loop Like a Functional Programing NativeLoop Like a Functional Programing Native
Loop Like a Functional Programing Native
 
Purely Functional Data Structures in Scala
Purely Functional Data Structures in ScalaPurely Functional Data Structures in Scala
Purely Functional Data Structures in Scala
 
Data structure , stack , queue
Data structure , stack , queueData structure , stack , queue
Data structure , stack , queue
 
Data structures in scala
Data structures in scalaData structures in scala
Data structures in scala
 
Lecture 4 data structures and algorithms
Lecture 4 data structures and algorithmsLecture 4 data structures and algorithms
Lecture 4 data structures and algorithms
 
Algo>ADT list & linked list
Algo>ADT list & linked listAlgo>ADT list & linked list
Algo>ADT list & linked list
 
Linked list
Linked listLinked list
Linked list
 
Data Structure (Dynamic Array and Linked List)
Data Structure (Dynamic Array and Linked List)Data Structure (Dynamic Array and Linked List)
Data Structure (Dynamic Array and Linked List)
 
Binary Search Tree
Binary Search TreeBinary Search Tree
Binary Search Tree
 
Data Structures in Python
Data Structures in PythonData Structures in Python
Data Structures in Python
 
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
 
1. python
1. python1. python
1. python
 
Data Structure (Circular Linked List)
Data Structure (Circular Linked List)Data Structure (Circular Linked List)
Data Structure (Circular Linked List)
 
Data structure lecture 5
Data structure lecture 5Data structure lecture 5
Data structure lecture 5
 
Link List
Link ListLink List
Link List
 
Data Structures - Lecture 7 [Linked List]
Data Structures - Lecture 7 [Linked List]Data Structures - Lecture 7 [Linked List]
Data Structures - Lecture 7 [Linked List]
 
Class 9: Consistent Hashing
Class 9: Consistent HashingClass 9: Consistent Hashing
Class 9: Consistent Hashing
 

Destaque

Lecture #1 - Introduction to Information System
Lecture #1 - Introduction to Information SystemLecture #1 - Introduction to Information System
Lecture #1 - Introduction to Information Systemvasanthimuniasamy
 
information system lecture notes
information system lecture notesinformation system lecture notes
information system lecture notesnaeem_mnm
 
Types o f information systems
Types o f information systemsTypes o f information systems
Types o f information systemsBimbashree K.G
 
Types Of Information Systems
Types Of Information SystemsTypes Of Information Systems
Types Of Information SystemsManuel Ardales
 
Management Information System (MIS)
Management Information System (MIS)Management Information System (MIS)
Management Information System (MIS)Navneet Jingar
 

Destaque (6)

Types of mis
Types of misTypes of mis
Types of mis
 
Lecture #1 - Introduction to Information System
Lecture #1 - Introduction to Information SystemLecture #1 - Introduction to Information System
Lecture #1 - Introduction to Information System
 
information system lecture notes
information system lecture notesinformation system lecture notes
information system lecture notes
 
Types o f information systems
Types o f information systemsTypes o f information systems
Types o f information systems
 
Types Of Information Systems
Types Of Information SystemsTypes Of Information Systems
Types Of Information Systems
 
Management Information System (MIS)
Management Information System (MIS)Management Information System (MIS)
Management Information System (MIS)
 

Semelhante a ARRAYS AND DATA STRUCTURES

VCE Unit 02 (1).pptx
VCE Unit 02 (1).pptxVCE Unit 02 (1).pptx
VCE Unit 02 (1).pptxskilljiolms
 
data structures and applications power p
data structures and applications power pdata structures and applications power p
data structures and applications power pMeghaKulkarni27
 
Binary Tree - Algorithms
Binary Tree - Algorithms Binary Tree - Algorithms
Binary Tree - Algorithms CourseHunt
 
Introduction to data structure by anil dutt
Introduction to data structure by anil duttIntroduction to data structure by anil dutt
Introduction to data structure by anil duttAnil Dutt
 
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
 
4 chapter3 list_stackqueuepart1
4 chapter3 list_stackqueuepart14 chapter3 list_stackqueuepart1
4 chapter3 list_stackqueuepart1SSE_AndyLi
 
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
 
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
 
Data Structure and Algorithm Lesson 2.pptx
Data Structure and Algorithm Lesson 2.pptxData Structure and Algorithm Lesson 2.pptx
Data Structure and Algorithm Lesson 2.pptxJoannahClaireAlforqu
 
Advanced s and s algorithm.ppt
Advanced s and s algorithm.pptAdvanced s and s algorithm.ppt
Advanced s and s algorithm.pptLegesseSamuel
 
Binary search tree
Binary search treeBinary search tree
Binary search treeSana Yameen
 
Trees in data structure
Trees in data structureTrees in data structure
Trees in data structureAnusruti Mitra
 

Semelhante a ARRAYS AND DATA STRUCTURES (20)

Data Structure
Data StructureData Structure
Data Structure
 
VCE Unit 02 (1).pptx
VCE Unit 02 (1).pptxVCE Unit 02 (1).pptx
VCE Unit 02 (1).pptx
 
data structures and applications power p
data structures and applications power pdata structures and applications power p
data structures and applications power p
 
unit 1.pptx
unit 1.pptxunit 1.pptx
unit 1.pptx
 
702 present
702 present702 present
702 present
 
Binary Tree - Algorithms
Binary Tree - Algorithms Binary Tree - Algorithms
Binary Tree - Algorithms
 
Introduction to data structure by anil dutt
Introduction to data structure by anil duttIntroduction to data structure by anil dutt
Introduction to data structure by anil dutt
 
Unit vii sorting
Unit   vii sorting Unit   vii sorting
Unit vii sorting
 
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
 
Dounly linked list
Dounly linked listDounly linked list
Dounly linked list
 
4 chapter3 list_stackqueuepart1
4 chapter3 list_stackqueuepart14 chapter3 list_stackqueuepart1
4 chapter3 list_stackqueuepart1
 
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
 
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 Structure and Algorithm Lesson 2.pptx
Data Structure and Algorithm Lesson 2.pptxData Structure and Algorithm Lesson 2.pptx
Data Structure and Algorithm Lesson 2.pptx
 
Lec 03 - Sorting.pptx
Lec 03 - Sorting.pptxLec 03 - Sorting.pptx
Lec 03 - Sorting.pptx
 
Advanced s and s algorithm.ppt
Advanced s and s algorithm.pptAdvanced s and s algorithm.ppt
Advanced s and s algorithm.ppt
 
Binary search tree
Binary search treeBinary search tree
Binary search tree
 
Trees in data structure
Trees in data structureTrees in data structure
Trees in data structure
 
Tree.pptx
Tree.pptxTree.pptx
Tree.pptx
 
Linked List.pptx
Linked List.pptxLinked List.pptx
Linked List.pptx
 

Último

How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitecturePixlogix Infotech
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Paola De la Torre
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 

Último (20)

How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 

ARRAYS AND DATA STRUCTURES

  • 1. ARRAY an array data structure or simply an array is a data structure consisting of a collection of elements (values orvariables), each identified by at least one array index or key. Applications Arrays are used to implement mathematical vectors and matrices, as well as other kinds of rectangular tables. One-dimensional arrays A one-dimensional array (or single dimension array) is a type of linear array. Accessing its elements involves a single subscript which can either represent a row or column index. As an example consider the C declaration int anArrayName[10]; Multidimensional arrays For a two-dimensional array, the element with indices i,j would have address B + c · i + d · j, where the coefficients c and d are the rowand column address increments, respectively. For example: int a[3][2]; STACK:: A stack is a list in which insertion and deletion take place at the same end This end is called top The other end is called bottom Stacks are known as LIFO (Last In, First Out) lists. The last element inserted will be the first to be retrieved Primary operations: Push and Pop Push Add an element to the top of the stack Pop Remove the element at the top of the stack Implementation of Stacks Any list implementation could be used to implement a stack Arrays (static: the size of stack is given initially) Linked lists (dynamic: never become full) CODE)CHECK IT LB=O; TOP=LB; INSEERTION WHILE TOP!= 4 READ X NUM[TOP]=X TOP=TOP+1 TOP=TOP-1 WHILE TOP!= -1 DELETION {TOP= TOP -1} QEUEE
  • 2. Like a stack, a queue is also a list. However, with a queue, insertion is done at one end, while deletion is performed at the other end. Accessing the elements of queues follows a First In, First Out (FIFO) order. Like customers standing in a check-out line in a store, the first customer in is the first customer served. Enqueue and Dequeue Primary queue operations: Enqueue and Dequeue Like check-out lines in a store, a queue has a front and a rear. Enqueue – insert an element at the rear of the queue Dequeue – remove an element from the front of the queue Implementation of Queue Just as stacks can be implemented as arrays or linked lists, so with queues. Dynamic queues have the same advantages over static queues as dynamic stacks have over static stacks Queue Implementation of Array There are several different algorithms to implement Enqueue and Dequeue Naïve way When enqueuing, the front index is always fixed and the rear index moves forward in the array. rear rear rear 3 3 6 3 6 9 front front front Enqueue(3) Enqueue(6) Enqueue(9) Naïve way (cont’d) When dequeuing, the front index is fixed, and the element at the front the queue is removed. Move all the elements after it by one position. (Inefficient!!!)
  • 3. rear rear rear = -1 6 9 9 front front front Dequeue() Dequeue() Dequeue() Delete ( ): Description: Here QUEUE is an array with N locations. FRONT and REAR points to the front and rear of the QUEUE. 1. If (FRONT == 0) Then [Check for underflow] 2. Print: Underflow 3. Else 4. ITEM = QUEUE[FRONT] 5. If (FRONT == REAR) Then [Check if only one element is left] (a) Set FRONT = 0 (b) Set REAR = 0 6. Else 7. Set FRONT = FRONT + 1 [Increment FRONT by 1] [End of Step 5 If] 8. Print: ITEM deleted [End of Insert ( ): Description: Here QUEUE is an array with N locations. FRONT and REAR points to the front and rear of the QUEUE. ITEM is the value to be inserted. 1. If (REAR == N) Then [Check for overflow] 2. Print: Overflow 3. Else 4. If (FRONT and REAR == 0) Then [Check if QUEUE is empty] (a) Set FRONT = 1 (b) Set REAR = 1 5. Else 6. Set REAR = REAR + 1 [Increment REAR by 1] [End of Step 4 If] 7. QUEUE[REAR] = ITEM 8. Print: ITEM inserted [End of Step 1 If] 9. Exit LINKLIST A linked list or one way list is a linear collection of data elements called nodes where the linear order is given by means of pointers. That is each node is divided into two parts the first part
  • 4. contains the address of the element and the second part called the link field or next pointer field contains the address of the next node in the list. The linked list can be of following types: 1. Linear Linked List or One Way List or Singly Linked List. 2. Doubly Linked List or Two Way List. 3. Circular Linked List. 4. Header Linked List. 5. Two Way Header Linked List. 6. Circular Header Linked List. 7. Two Way Circular Header Linked List • Types of linked lists: – Singly linked list • Begins with a pointer to the first node • Terminates with a null pointer • Only traversed in one direction – Circular, singly linked • Pointer in the last node points back to the first node – Doubly linked list • Two “start pointers” – first element and last element • Each node has a forward pointer and a backward pointer • Allows traversals both forwards and backwards – Circular, doubly linked list • Forward pointer of the last node points to the first node and backward pointer of the first node points to the last node Header Linked List. Header Linked List: A header linked list which always contains a special node, called the header node, at the beginning of the list. The following are two kinds of widely used header list: 1. A grounded header list is a header list where the last node contains the null pointer. 2. A circular header list is a header list where the last node points back to the header node. Unless otherwise stated or implied, our header list will always be circular list. Accordingly, in such a case, the header node also acts as a sentinel indicating the end of the list. Header Linked List . Two Way Header Linked List. The two-way list is a linear collection of data elements called nodes where each node is divided into three parts: 1. An information field INFO which contains the data of N 2. A pointer field FORW which contains the location of the next node in the list. 3. A pointer field BACK which contains the location of the preceding node in the list.
  • 5. The list also requires two list pointer variables: FIRST, which points to the first node in the list, and LAST, which points to the last node in the list. Observe that the null pointer appears in the FORW field of the last node in the list and also in the BACK field of the first node in the list. TREE (inorder, preorder, postfix, memory representation by array and link list) • Tree nodes contain two or more links – All other data structures we have discussed only contain one • Binary trees – All nodes contain two links • None, one, or both of which may be NULL – The root node is the first node in a tree. – Each link in the root node refers to a child – A node with no children is called a leaf node • Binary search tree – Values in left sub tree less than parent – Values in right sub tree greater than parent – Facilitates duplicate elimination – Fast searches - for a balanced tree, maximum of log n comparisons
  • 6. 4 7 2 7 5 7 1 4 6 93 1 3 5 7 17 3 44 6 1 8 • Tree traversals: – In order traversal – prints the node values in ascending order 1. Traverse the left sub tree with an in order traversal 2. Process the value in the node (i.e., print the node value) 3. Traverse the right sub tree with an in order traversal – Preorder traversal 1. Process the value in the node 2. Traverse the left sub tree with a preorder traversal 3. Traverse the right sub tree with a preorder traversal – Post order traversal 1. Traverse the left subtree with a postorder traversal 2. Traverse the right subtree with a postorder traversal 3. Process the value in the node For example can be represented by the array Suppose we would like to represent the following tree in memory, using only lists (which are created by chaining conses). You should already know how acons is created and what parts constitute one. If not, go back to an introductory book on Common Lisp.
  • 7. This tree can be represented as a set of linked lists, like in the following diagram: The natural way to represent the previous tree as a Common Lisp list is like the following: (1 (2 6 7 8) 3 (4 (9 12)) (5 10 11)) The first element of a list is the root of that tree (or a node) and the rest of the elements are the subtrees (more nodes). For example, the subtree (2 6 7 8)is a tree with “2” at its root and the elements “6 7 8” as its children. Graph definition A graph is a collection of nodes called vertices, and the connections between them, called edges. An example The following diagram shows a graph with 5 vertices and 7 edges. The edges between A and D and B and C are pairs that make a bidirectional connection, represented here by a double-headed arrow.
  • 8. disjkstra algorithm to find shortest path The indented lines under a given line are done under the condition that line. Once that condition is no longer met you move on in the algorithm. The first part of the algorithm is an initialization of the graph into the setup described earlier; the rest is concerned with searching through the graph to find distances. To illustrate the algorithm we provide an example below. In the above picture o is marked by a double circle. The Unburned node with the smallest &delta value is orange. It will be burned at the next step in the algorithm. The yellow vertex is the one that is currently burning. Gray vertices have been labeled as Burned by the algorithm. Neighbors if the burning vertex whose &delta is being updated have their edges marked in orange. This happens when δ(u) + w(u,n) < &delta(n). Edges corresponding to sources are marked in blue. Note that the algorithm will occasionally overwrite the source of a vertex with a closer source. Once all the vertices are Burned the algorithm is burned. Now that we've run the algorithm how do we find the shortest path from o to another vertex? We simply follow thesource edges (blue in the example) from the destination until we reach o, and the distance we have travelled corresponds to the label &delta on the destination. We also know that we have actually found the shortest path (it is possible to have more than one path tied for being the shortest) since our fire has always chosen to take the shortest steps possible when moving to a new location. You might have already noticed that the blue subgraph doesn't contain any loops, and this is what mathematicians call a tree. In fact this is a very special kind of tree called a minimal spanning tree because it grows from the root o to all of its leaves, the other vertices in G, in the shortest way possible. Minimal spanning trees are very useful. For instance, if a cable company needs to wire all the houses in a neighborhood using as little wire as possible, a minimal spanning tree of the neighborhood provides them with the most efficient way to do so.
  • 9. Game tree (definiton) games) game tree - A tree representing contingencies in a game. Each node in a game tree represents a possible position (e.g., possible configuration of pieces on a chessboard) in the game, and each branching ("edge" in graph terms) represents a possible move. A constructor gets called automatically when you create an object of a class; if you define your own constructor, by default a constructor is called which is the Default Constructor. A class can have more than one constructor. It has the same name as the class itself. Destructors are again methods of a class that enable the destruction of an object after its use; destructors also provide the means of memory clean up after usage. Destructors are always called in the reverse order of Constructors. There can only be one destructor per class and they neither take an input parameter nor do they return anything. Destructors need not be called explicitly. Code: class Vehicle { Int Registration = 0; public: Vehicle(int regis) // constructor { Registration = regis; } Virtual void GetRegistration() = 0; ~Vehicle() // destructor { } ATTRIBUTE FUNCTION In GNU C, you declare certain things about functions called in your program which help the compiler optimize function calls and check your code more carefully. The keyword `__attribute__' allows you to specify special attributes when making a declaration. This keyword is followed by an attribute specification inside double parentheses. void fatal () __attribute__ ((noreturn)); void fatal (...) { ... /* Print error message. */ ... exit (1); } Attribute Member The member attribute is a multi-value attribute that contains the list of distinguished names for the user, group, and contact objects that are members of the group. Each item in the list is a linked
  • 10. reference to the object that represents the member; therefore, the Active Directory server automatically updates the distinguished names in the member property when a member object is moved or renamed.