SlideShare a Scribd company logo
Static arrays are structures whose size is fixed at compile time and therefore cannot be extended
or reduced to fit the data set. A dynamic array can be extended by doubling the size but there is
overhead associated with the operation of copying old data and freeing the memory associated
with the old data structure. One potential problem of using arrays for storing data is that arrays
require a contiguous block of memory which may not be available, if the requested contiguous
block is too large. However the advantages of using arrays are that each element in the array can
be accessed very efficiently using an index. However, for applications that can be better
managed without using contiguous memory we define a concept called “linked lists”.
A linked list is a collection of objects linked together by references from one object to another
object. By convention these objects are named as nodes. So the basic linked list is collection of
nodes where each node contains one or more data fields AND a reference to the next node. The
last node points to a NULL reference to indicate the end of the list.
Types of Linked Lists
Linked lists are widely used in many applications because of the flexibility it provides. Unlike
arrays that are dynamically assigned, linked lists do not require memory from a contiguous
block. This makes it very appealing to store data in a linked list, when the data set is large or
device (eg: PDA) has limited memory. One of the disadvantages of linked lists is that they are
not random accessed like arrays. To find information in a linked list one must start from the head
of the list and traverse the list sequentially until it finds (or not find) the node. Another advantage
of linked lists over arrays is that when a node is inserted or deleted, there is no need to “adjust”
the array.
There are few different types of linked lists. A singly linked list as described above provides
access to the list from the head node. Traversal is allowed only one way and there is no going
back. A doubly linked list is a list that has two references, one to the next node and another to
previous node. Doubly linked list also starts from head node, but provide access both ways. That
is one can traverse forward or backward from any node. A multilinked list (see figures 1 & 2) is
a more general linked list with multiple links from nodes. For examples, we can define a Node
that has two references, age pointer and a name pointer. With this structure it is possible to
maintain a single list, where if we follow the name pointer we can traverse the list in alphabetical
order of names and if we traverse the age pointer, we can traverse the list sorted by ages. This
type of node organization may be useful for maintaining a customer list in a bank where same
list can be traversed in any order (name, age, or any other criteria) based on the need.
Designing the Node of a Linked List
Linked list is a collection of linked nodes. A node is a struct with at least a data field and a
reference to a node of the same type. A node is called a self-referential object, since it contains a
pointer to a variable that refers to a variable of the same type. For example, a struct Node that
contains an int data field and a pointer to another node can be defined as follows.
typedef struct node {
int data;
struct node* next;
} node;
node* head = NULL;
Creating the first node
Memory must be allocated for one node and assigned to head as follows.
head = (node*) malloc(sizeof(node));
headdata = 10;
headnext = NULL;
Adding the second node and linking
node* nextnode = malloc(sizeof(node));
nextnodedata = 12;
nextnodenext = NULL;
headnext = nextnode;
Linked list is a data structure in which the items are ordered in a linear way. Although modern
programming languages support very flexible and rich libraries that works with arrays, which use
arrays to represent lists, the principles of building a linked list remain very important. The way
linked lists are implemented is a ground level in order to build more complex data structures
such as trees.
It’s true that almost every operation we can perform on a linked list can be done with an array.
It’s also true that some operations can be faster on arrays compared to linked lists.
However understanding how to implement the basic operations of a linked list such as INSERT,
DELETE, INSERT_AFTER, PRINT and so on is crucial in order to implement data structures as
rooted trees, B-trees, red-black trees, etc.
Big-O notation is a way to express the efficiency of an algorithm. If you’re going to be working
with code, it is extremely important that you understand Big-O. It is, quite literally, the language
we use to express efficiency.
Big-O is an expression of how the execution time of a program scales with the input data. That
is, as the input gets bigger, how much longer will the program take? Just a little bit? A lot
longer?
Suppose you have a function for which does some processing on an array of size N. If foo takes
O(N) time, then, as the array grows (that is, as N increases), the number of seconds foo takes will
also increase in some sort of linear fashion.
The first decision in planning the linked-list implementation of the Queue class is which end of
the list will correspond to the front of the queue. Recall that items need to be added to the rear of
the queue, and removed from the front of the queue. Therefore, we should make our choice
based on whether it is easier to add/remove a node from the front/end of a linked list.
If we keep pointers to both the first and last nodes of the list, we can add a node at either end in
constant time. However, while we can remove the first node in the list in constant time,
removing the last node requires first locating the previous node, which takes time proportional to
the length of the list. Therefore, we should choose to make the end of the list be the rear of the
queue, and the front of the list be the front of the queue.
Other than saving space, the first advantage I can see for singly linked lists over doubly linked
lists is to avoid having to update two links instead of one when you modify the list, when adding
an element for example.
Of course, one might say that you can always ignore the second link, but in that case, it is no
longer doubly linked, but only an unused field.What might also be seen as an advantage is that
singly linked list are necessarily consistent, though possibly wrong when there are bugs in the
program. Doubly linked lists can end-up having inconsistent links forward and backward. But it
is debatable which of the two cases, if any, is an advantage.
update:
I had tried to see some impact on garbage collection, but found none. Actually, there is one when
storage reclamation is done by reference counting, as reference counting is defeated by loops,
and doubly linked lists contain loops. Singly linked list escape the problem. Of course, there are
ways around it for doubly linked lists, such as the use of weak pointers, or programmable
reference counting as part of data abstraction.
Solution
Static arrays are structures whose size is fixed at compile time and therefore cannot be extended
or reduced to fit the data set. A dynamic array can be extended by doubling the size but there is
overhead associated with the operation of copying old data and freeing the memory associated
with the old data structure. One potential problem of using arrays for storing data is that arrays
require a contiguous block of memory which may not be available, if the requested contiguous
block is too large. However the advantages of using arrays are that each element in the array can
be accessed very efficiently using an index. However, for applications that can be better
managed without using contiguous memory we define a concept called “linked lists”.
A linked list is a collection of objects linked together by references from one object to another
object. By convention these objects are named as nodes. So the basic linked list is collection of
nodes where each node contains one or more data fields AND a reference to the next node. The
last node points to a NULL reference to indicate the end of the list.
Types of Linked Lists
Linked lists are widely used in many applications because of the flexibility it provides. Unlike
arrays that are dynamically assigned, linked lists do not require memory from a contiguous
block. This makes it very appealing to store data in a linked list, when the data set is large or
device (eg: PDA) has limited memory. One of the disadvantages of linked lists is that they are
not random accessed like arrays. To find information in a linked list one must start from the head
of the list and traverse the list sequentially until it finds (or not find) the node. Another advantage
of linked lists over arrays is that when a node is inserted or deleted, there is no need to “adjust”
the array.
There are few different types of linked lists. A singly linked list as described above provides
access to the list from the head node. Traversal is allowed only one way and there is no going
back. A doubly linked list is a list that has two references, one to the next node and another to
previous node. Doubly linked list also starts from head node, but provide access both ways. That
is one can traverse forward or backward from any node. A multilinked list (see figures 1 & 2) is
a more general linked list with multiple links from nodes. For examples, we can define a Node
that has two references, age pointer and a name pointer. With this structure it is possible to
maintain a single list, where if we follow the name pointer we can traverse the list in alphabetical
order of names and if we traverse the age pointer, we can traverse the list sorted by ages. This
type of node organization may be useful for maintaining a customer list in a bank where same
list can be traversed in any order (name, age, or any other criteria) based on the need.
Designing the Node of a Linked List
Linked list is a collection of linked nodes. A node is a struct with at least a data field and a
reference to a node of the same type. A node is called a self-referential object, since it contains a
pointer to a variable that refers to a variable of the same type. For example, a struct Node that
contains an int data field and a pointer to another node can be defined as follows.
typedef struct node {
int data;
struct node* next;
} node;
node* head = NULL;
Creating the first node
Memory must be allocated for one node and assigned to head as follows.
head = (node*) malloc(sizeof(node));
headdata = 10;
headnext = NULL;
Adding the second node and linking
node* nextnode = malloc(sizeof(node));
nextnodedata = 12;
nextnodenext = NULL;
headnext = nextnode;
Linked list is a data structure in which the items are ordered in a linear way. Although modern
programming languages support very flexible and rich libraries that works with arrays, which use
arrays to represent lists, the principles of building a linked list remain very important. The way
linked lists are implemented is a ground level in order to build more complex data structures
such as trees.
It’s true that almost every operation we can perform on a linked list can be done with an array.
It’s also true that some operations can be faster on arrays compared to linked lists.
However understanding how to implement the basic operations of a linked list such as INSERT,
DELETE, INSERT_AFTER, PRINT and so on is crucial in order to implement data structures as
rooted trees, B-trees, red-black trees, etc.
Big-O notation is a way to express the efficiency of an algorithm. If you’re going to be working
with code, it is extremely important that you understand Big-O. It is, quite literally, the language
we use to express efficiency.
Big-O is an expression of how the execution time of a program scales with the input data. That
is, as the input gets bigger, how much longer will the program take? Just a little bit? A lot
longer?
Suppose you have a function for which does some processing on an array of size N. If foo takes
O(N) time, then, as the array grows (that is, as N increases), the number of seconds foo takes will
also increase in some sort of linear fashion.
The first decision in planning the linked-list implementation of the Queue class is which end of
the list will correspond to the front of the queue. Recall that items need to be added to the rear of
the queue, and removed from the front of the queue. Therefore, we should make our choice
based on whether it is easier to add/remove a node from the front/end of a linked list.
If we keep pointers to both the first and last nodes of the list, we can add a node at either end in
constant time. However, while we can remove the first node in the list in constant time,
removing the last node requires first locating the previous node, which takes time proportional to
the length of the list. Therefore, we should choose to make the end of the list be the rear of the
queue, and the front of the list be the front of the queue.
Other than saving space, the first advantage I can see for singly linked lists over doubly linked
lists is to avoid having to update two links instead of one when you modify the list, when adding
an element for example.
Of course, one might say that you can always ignore the second link, but in that case, it is no
longer doubly linked, but only an unused field.What might also be seen as an advantage is that
singly linked list are necessarily consistent, though possibly wrong when there are bugs in the
program. Doubly linked lists can end-up having inconsistent links forward and backward. But it
is debatable which of the two cases, if any, is an advantage.
update:
I had tried to see some impact on garbage collection, but found none. Actually, there is one when
storage reclamation is done by reference counting, as reference counting is defeated by loops,
and doubly linked lists contain loops. Singly linked list escape the problem. Of course, there are
ways around it for doubly linked lists, such as the use of weak pointers, or programmable
reference counting as part of data abstraction.

More Related Content

Similar to Static arrays are structures whose size is fixed at compile time and.pdf

Data Structures- Part7 linked lists
Data Structures- Part7 linked listsData Structures- Part7 linked lists
Data Structures- Part7 linked lists
Abdullah Al-hazmy
 
Ap Power Point Chpt9
Ap Power Point Chpt9Ap Power Point Chpt9
Ap Power Point Chpt9dplunkett
 
2 Important Data Structure Interview Questions
2 Important Data Structure Interview Questions2 Important Data Structure Interview Questions
2 Important Data Structure Interview Questions
Geekster
 
2 marks- DS using python
2 marks- DS using python2 marks- DS using python
2 marks- DS using python
LavanyaJ28
 
linked_lists
linked_listslinked_lists
linked_lists
Mohamed Elsayed
 
Data Structures & Algorithms Unit 1.pptx
Data Structures & Algorithms Unit 1.pptxData Structures & Algorithms Unit 1.pptx
Data Structures & Algorithms Unit 1.pptx
UsriDevi1
 
linked list.pptx
linked list.pptxlinked list.pptx
linked list.pptx
DarbhalaPavanKumar
 
Link list
Link listLink list
Link list
zzzubair
 
Indexing techniques
Indexing techniquesIndexing techniques
Indexing techniques
Huda Alameen
 
1.3 Linked List.pptx
1.3 Linked List.pptx1.3 Linked List.pptx
1.3 Linked List.pptx
ssuserd2f031
 
02 linked list_20160217_jintaekseo
02 linked list_20160217_jintaekseo02 linked list_20160217_jintaekseo
02 linked list_20160217_jintaekseo
JinTaek Seo
 
Introduction to Data Structure
Introduction to Data StructureIntroduction to Data Structure
Introduction to Data StructureJazz Jinia Bhowmik
 
Notes of bca Question paper for exams and tests
Notes of bca Question paper for exams and testsNotes of bca Question paper for exams and tests
Notes of bca Question paper for exams and tests
priyanshukumar97908
 
2. Introduction to Data Structure.pdf
2. Introduction to Data Structure.pdf2. Introduction to Data Structure.pdf
2. Introduction to Data Structure.pdf
SulabhPawaia
 
csc211_lecture_21.pptx
csc211_lecture_21.pptxcsc211_lecture_21.pptx
csc211_lecture_21.pptx
ASADAHMAD811380
 
Linear Data Structures - List, Stack and Queue
Linear Data Structures - List, Stack and QueueLinear Data Structures - List, Stack and Queue
Linear Data Structures - List, Stack and Queue
Selvaraj Seerangan
 
Different types of Linked list.
Different types of Linked list.Different types of Linked list.
Different types of Linked list.
JAYANTAOJHA
 
Key,ID Field and Tables Relationship
Key,ID Field and Tables Relationship Key,ID Field and Tables Relationship
Key,ID Field and Tables Relationship
ShouaQureshi
 
Which data structure is it? What are the various data structure kinds and wha...
Which data structure is it? What are the various data structure kinds and wha...Which data structure is it? What are the various data structure kinds and wha...
Which data structure is it? What are the various data structure kinds and wha...
Tutort Academy
 
Introduction to linked lists
Introduction to linked listsIntroduction to linked lists
Introduction to linked lists
pooja kumari
 

Similar to Static arrays are structures whose size is fixed at compile time and.pdf (20)

Data Structures- Part7 linked lists
Data Structures- Part7 linked listsData Structures- Part7 linked lists
Data Structures- Part7 linked lists
 
Ap Power Point Chpt9
Ap Power Point Chpt9Ap Power Point Chpt9
Ap Power Point Chpt9
 
2 Important Data Structure Interview Questions
2 Important Data Structure Interview Questions2 Important Data Structure Interview Questions
2 Important Data Structure Interview Questions
 
2 marks- DS using python
2 marks- DS using python2 marks- DS using python
2 marks- DS using python
 
linked_lists
linked_listslinked_lists
linked_lists
 
Data Structures & Algorithms Unit 1.pptx
Data Structures & Algorithms Unit 1.pptxData Structures & Algorithms Unit 1.pptx
Data Structures & Algorithms Unit 1.pptx
 
linked list.pptx
linked list.pptxlinked list.pptx
linked list.pptx
 
Link list
Link listLink list
Link list
 
Indexing techniques
Indexing techniquesIndexing techniques
Indexing techniques
 
1.3 Linked List.pptx
1.3 Linked List.pptx1.3 Linked List.pptx
1.3 Linked List.pptx
 
02 linked list_20160217_jintaekseo
02 linked list_20160217_jintaekseo02 linked list_20160217_jintaekseo
02 linked list_20160217_jintaekseo
 
Introduction to Data Structure
Introduction to Data StructureIntroduction to Data Structure
Introduction to Data Structure
 
Notes of bca Question paper for exams and tests
Notes of bca Question paper for exams and testsNotes of bca Question paper for exams and tests
Notes of bca Question paper for exams and tests
 
2. Introduction to Data Structure.pdf
2. Introduction to Data Structure.pdf2. Introduction to Data Structure.pdf
2. Introduction to Data Structure.pdf
 
csc211_lecture_21.pptx
csc211_lecture_21.pptxcsc211_lecture_21.pptx
csc211_lecture_21.pptx
 
Linear Data Structures - List, Stack and Queue
Linear Data Structures - List, Stack and QueueLinear Data Structures - List, Stack and Queue
Linear Data Structures - List, Stack and Queue
 
Different types of Linked list.
Different types of Linked list.Different types of Linked list.
Different types of Linked list.
 
Key,ID Field and Tables Relationship
Key,ID Field and Tables Relationship Key,ID Field and Tables Relationship
Key,ID Field and Tables Relationship
 
Which data structure is it? What are the various data structure kinds and wha...
Which data structure is it? What are the various data structure kinds and wha...Which data structure is it? What are the various data structure kinds and wha...
Which data structure is it? What are the various data structure kinds and wha...
 
Introduction to linked lists
Introduction to linked listsIntroduction to linked lists
Introduction to linked lists
 

More from anjanacottonmills

Step1 First compound has 2 double bonds ; Second .pdf
                     Step1 First compound has 2 double bonds ; Second .pdf                     Step1 First compound has 2 double bonds ; Second .pdf
Step1 First compound has 2 double bonds ; Second .pdf
anjanacottonmills
 
Molarity = molesvolume9liter) Molarity of NH4Cl.pdf
                     Molarity = molesvolume9liter)  Molarity of NH4Cl.pdf                     Molarity = molesvolume9liter)  Molarity of NH4Cl.pdf
Molarity = molesvolume9liter) Molarity of NH4Cl.pdf
anjanacottonmills
 
HOCH2CH2OH is more soluble in water. more OH grou.pdf
                     HOCH2CH2OH is more soluble in water. more OH grou.pdf                     HOCH2CH2OH is more soluble in water. more OH grou.pdf
HOCH2CH2OH is more soluble in water. more OH grou.pdf
anjanacottonmills
 
x = -2Solutionx = -2.pdf
x = -2Solutionx = -2.pdfx = -2Solutionx = -2.pdf
x = -2Solutionx = -2.pdf
anjanacottonmills
 
z=(2n+1)4where n=all integersSolutionz=(2n+1)4where n=al.pdf
z=(2n+1)4where n=all integersSolutionz=(2n+1)4where n=al.pdfz=(2n+1)4where n=all integersSolutionz=(2n+1)4where n=al.pdf
z=(2n+1)4where n=all integersSolutionz=(2n+1)4where n=al.pdf
anjanacottonmills
 
This above plant name is Solidago sempervirens, belong to genus Soli.pdf
This above plant name is Solidago sempervirens, belong to genus Soli.pdfThis above plant name is Solidago sempervirens, belong to genus Soli.pdf
This above plant name is Solidago sempervirens, belong to genus Soli.pdf
anjanacottonmills
 
The Java Program for the above given isimport java.io.File;impo.pdf
The Java Program for the above given isimport java.io.File;impo.pdfThe Java Program for the above given isimport java.io.File;impo.pdf
The Java Program for the above given isimport java.io.File;impo.pdf
anjanacottonmills
 
The fidelity of DNA replication determines the genome stability and .pdf
The fidelity of DNA replication determines the genome stability and .pdfThe fidelity of DNA replication determines the genome stability and .pdf
The fidelity of DNA replication determines the genome stability and .pdf
anjanacottonmills
 
E= 0.28V reactants are favored .pdf
                     E= 0.28V reactants are favored                   .pdf                     E= 0.28V reactants are favored                   .pdf
E= 0.28V reactants are favored .pdf
anjanacottonmills
 
The differences between ipv4 and ipv6 are as below1. Header1.Ch.pdf
The differences between ipv4 and ipv6 are as below1. Header1.Ch.pdfThe differences between ipv4 and ipv6 are as below1. Header1.Ch.pdf
The differences between ipv4 and ipv6 are as below1. Header1.Ch.pdf
anjanacottonmills
 
TCP - TCP breaks data into manageable packets and tracks information.pdf
TCP - TCP breaks data into manageable packets and tracks information.pdfTCP - TCP breaks data into manageable packets and tracks information.pdf
TCP - TCP breaks data into manageable packets and tracks information.pdf
anjanacottonmills
 
D) II, III, IV, and V only .pdf
                     D) II, III, IV, and V only                       .pdf                     D) II, III, IV, and V only                       .pdf
D) II, III, IV, and V only .pdf
anjanacottonmills
 
NumberList.java (implements the linked list)public class NumberLis.pdf
NumberList.java (implements the linked list)public class NumberLis.pdfNumberList.java (implements the linked list)public class NumberLis.pdf
NumberList.java (implements the linked list)public class NumberLis.pdf
anjanacottonmills
 
c) H2(g) + 12 O2(g) -H2O (l) as all are in the.pdf
                     c) H2(g) + 12 O2(g) -H2O (l)  as all are in the.pdf                     c) H2(g) + 12 O2(g) -H2O (l)  as all are in the.pdf
c) H2(g) + 12 O2(g) -H2O (l) as all are in the.pdf
anjanacottonmills
 
MagicSquareTest.java import java.util.Scanner;public class Mag.pdf
MagicSquareTest.java import java.util.Scanner;public class Mag.pdfMagicSquareTest.java import java.util.Scanner;public class Mag.pdf
MagicSquareTest.java import java.util.Scanner;public class Mag.pdf
anjanacottonmills
 
Interphase.This is the phase where the cell prepares for the next .pdf
Interphase.This is the phase where the cell prepares for the next .pdfInterphase.This is the phase where the cell prepares for the next .pdf
Interphase.This is the phase where the cell prepares for the next .pdf
anjanacottonmills
 
B.the rotation will be zero as L and D will cance.pdf
                     B.the rotation will be zero as L and D will cance.pdf                     B.the rotation will be zero as L and D will cance.pdf
B.the rotation will be zero as L and D will cance.pdf
anjanacottonmills
 
In the above conversation it is belonging to stereotypes.Stereotyp.pdf
In the above conversation it is belonging to stereotypes.Stereotyp.pdfIn the above conversation it is belonging to stereotypes.Stereotyp.pdf
In the above conversation it is belonging to stereotypes.Stereotyp.pdf
anjanacottonmills
 
In general, the objective of an audit is to assess the risk of mater.pdf
In general, the objective of an audit is to assess the risk of mater.pdfIn general, the objective of an audit is to assess the risk of mater.pdf
In general, the objective of an audit is to assess the risk of mater.pdf
anjanacottonmills
 
if one can understand a few things it is easier to solve these kind .pdf
if one can understand a few things it is easier to solve these kind .pdfif one can understand a few things it is easier to solve these kind .pdf
if one can understand a few things it is easier to solve these kind .pdf
anjanacottonmills
 

More from anjanacottonmills (20)

Step1 First compound has 2 double bonds ; Second .pdf
                     Step1 First compound has 2 double bonds ; Second .pdf                     Step1 First compound has 2 double bonds ; Second .pdf
Step1 First compound has 2 double bonds ; Second .pdf
 
Molarity = molesvolume9liter) Molarity of NH4Cl.pdf
                     Molarity = molesvolume9liter)  Molarity of NH4Cl.pdf                     Molarity = molesvolume9liter)  Molarity of NH4Cl.pdf
Molarity = molesvolume9liter) Molarity of NH4Cl.pdf
 
HOCH2CH2OH is more soluble in water. more OH grou.pdf
                     HOCH2CH2OH is more soluble in water. more OH grou.pdf                     HOCH2CH2OH is more soluble in water. more OH grou.pdf
HOCH2CH2OH is more soluble in water. more OH grou.pdf
 
x = -2Solutionx = -2.pdf
x = -2Solutionx = -2.pdfx = -2Solutionx = -2.pdf
x = -2Solutionx = -2.pdf
 
z=(2n+1)4where n=all integersSolutionz=(2n+1)4where n=al.pdf
z=(2n+1)4where n=all integersSolutionz=(2n+1)4where n=al.pdfz=(2n+1)4where n=all integersSolutionz=(2n+1)4where n=al.pdf
z=(2n+1)4where n=all integersSolutionz=(2n+1)4where n=al.pdf
 
This above plant name is Solidago sempervirens, belong to genus Soli.pdf
This above plant name is Solidago sempervirens, belong to genus Soli.pdfThis above plant name is Solidago sempervirens, belong to genus Soli.pdf
This above plant name is Solidago sempervirens, belong to genus Soli.pdf
 
The Java Program for the above given isimport java.io.File;impo.pdf
The Java Program for the above given isimport java.io.File;impo.pdfThe Java Program for the above given isimport java.io.File;impo.pdf
The Java Program for the above given isimport java.io.File;impo.pdf
 
The fidelity of DNA replication determines the genome stability and .pdf
The fidelity of DNA replication determines the genome stability and .pdfThe fidelity of DNA replication determines the genome stability and .pdf
The fidelity of DNA replication determines the genome stability and .pdf
 
E= 0.28V reactants are favored .pdf
                     E= 0.28V reactants are favored                   .pdf                     E= 0.28V reactants are favored                   .pdf
E= 0.28V reactants are favored .pdf
 
The differences between ipv4 and ipv6 are as below1. Header1.Ch.pdf
The differences between ipv4 and ipv6 are as below1. Header1.Ch.pdfThe differences between ipv4 and ipv6 are as below1. Header1.Ch.pdf
The differences between ipv4 and ipv6 are as below1. Header1.Ch.pdf
 
TCP - TCP breaks data into manageable packets and tracks information.pdf
TCP - TCP breaks data into manageable packets and tracks information.pdfTCP - TCP breaks data into manageable packets and tracks information.pdf
TCP - TCP breaks data into manageable packets and tracks information.pdf
 
D) II, III, IV, and V only .pdf
                     D) II, III, IV, and V only                       .pdf                     D) II, III, IV, and V only                       .pdf
D) II, III, IV, and V only .pdf
 
NumberList.java (implements the linked list)public class NumberLis.pdf
NumberList.java (implements the linked list)public class NumberLis.pdfNumberList.java (implements the linked list)public class NumberLis.pdf
NumberList.java (implements the linked list)public class NumberLis.pdf
 
c) H2(g) + 12 O2(g) -H2O (l) as all are in the.pdf
                     c) H2(g) + 12 O2(g) -H2O (l)  as all are in the.pdf                     c) H2(g) + 12 O2(g) -H2O (l)  as all are in the.pdf
c) H2(g) + 12 O2(g) -H2O (l) as all are in the.pdf
 
MagicSquareTest.java import java.util.Scanner;public class Mag.pdf
MagicSquareTest.java import java.util.Scanner;public class Mag.pdfMagicSquareTest.java import java.util.Scanner;public class Mag.pdf
MagicSquareTest.java import java.util.Scanner;public class Mag.pdf
 
Interphase.This is the phase where the cell prepares for the next .pdf
Interphase.This is the phase where the cell prepares for the next .pdfInterphase.This is the phase where the cell prepares for the next .pdf
Interphase.This is the phase where the cell prepares for the next .pdf
 
B.the rotation will be zero as L and D will cance.pdf
                     B.the rotation will be zero as L and D will cance.pdf                     B.the rotation will be zero as L and D will cance.pdf
B.the rotation will be zero as L and D will cance.pdf
 
In the above conversation it is belonging to stereotypes.Stereotyp.pdf
In the above conversation it is belonging to stereotypes.Stereotyp.pdfIn the above conversation it is belonging to stereotypes.Stereotyp.pdf
In the above conversation it is belonging to stereotypes.Stereotyp.pdf
 
In general, the objective of an audit is to assess the risk of mater.pdf
In general, the objective of an audit is to assess the risk of mater.pdfIn general, the objective of an audit is to assess the risk of mater.pdf
In general, the objective of an audit is to assess the risk of mater.pdf
 
if one can understand a few things it is easier to solve these kind .pdf
if one can understand a few things it is easier to solve these kind .pdfif one can understand a few things it is easier to solve these kind .pdf
if one can understand a few things it is easier to solve these kind .pdf
 

Recently uploaded

A Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in EducationA Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in Education
Peter Windle
 
The Accursed House by Émile Gaboriau.pptx
The Accursed House by Émile Gaboriau.pptxThe Accursed House by Émile Gaboriau.pptx
The Accursed House by Émile Gaboriau.pptx
DhatriParmar
 
Honest Reviews of Tim Han LMA Course Program.pptx
Honest Reviews of Tim Han LMA Course Program.pptxHonest Reviews of Tim Han LMA Course Program.pptx
Honest Reviews of Tim Han LMA Course Program.pptx
timhan337
 
Introduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp NetworkIntroduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp Network
TechSoup
 
Group Presentation 2 Economics.Ariana Buscigliopptx
Group Presentation 2 Economics.Ariana BuscigliopptxGroup Presentation 2 Economics.Ariana Buscigliopptx
Group Presentation 2 Economics.Ariana Buscigliopptx
ArianaBusciglio
 
Multithreading_in_C++ - std::thread, race condition
Multithreading_in_C++ - std::thread, race conditionMultithreading_in_C++ - std::thread, race condition
Multithreading_in_C++ - std::thread, race condition
Mohammed Sikander
 
Lapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdfLapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdf
Jean Carlos Nunes Paixão
 
Supporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptxSupporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptx
Jisc
 
Embracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic ImperativeEmbracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic Imperative
Peter Windle
 
Francesca Gottschalk - How can education support child empowerment.pptx
Francesca Gottschalk - How can education support child empowerment.pptxFrancesca Gottschalk - How can education support child empowerment.pptx
Francesca Gottschalk - How can education support child empowerment.pptx
EduSkills OECD
 
Digital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and ResearchDigital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and Research
Vikramjit Singh
 
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
EugeneSaldivar
 
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
Nguyen Thanh Tu Collection
 
Language Across the Curriculm LAC B.Ed.
Language Across the  Curriculm LAC B.Ed.Language Across the  Curriculm LAC B.Ed.
Language Across the Curriculm LAC B.Ed.
Atul Kumar Singh
 
Unit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdfUnit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdf
Thiyagu K
 
Marketing internship report file for MBA
Marketing internship report file for MBAMarketing internship report file for MBA
Marketing internship report file for MBA
gb193092
 
Normal Labour/ Stages of Labour/ Mechanism of Labour
Normal Labour/ Stages of Labour/ Mechanism of LabourNormal Labour/ Stages of Labour/ Mechanism of Labour
Normal Labour/ Stages of Labour/ Mechanism of Labour
Wasim Ak
 
The French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free downloadThe French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free download
Vivekanand Anglo Vedic Academy
 
Model Attribute Check Company Auto Property
Model Attribute  Check Company Auto PropertyModel Attribute  Check Company Auto Property
Model Attribute Check Company Auto Property
Celine George
 
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
MysoreMuleSoftMeetup
 

Recently uploaded (20)

A Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in EducationA Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in Education
 
The Accursed House by Émile Gaboriau.pptx
The Accursed House by Émile Gaboriau.pptxThe Accursed House by Émile Gaboriau.pptx
The Accursed House by Émile Gaboriau.pptx
 
Honest Reviews of Tim Han LMA Course Program.pptx
Honest Reviews of Tim Han LMA Course Program.pptxHonest Reviews of Tim Han LMA Course Program.pptx
Honest Reviews of Tim Han LMA Course Program.pptx
 
Introduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp NetworkIntroduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp Network
 
Group Presentation 2 Economics.Ariana Buscigliopptx
Group Presentation 2 Economics.Ariana BuscigliopptxGroup Presentation 2 Economics.Ariana Buscigliopptx
Group Presentation 2 Economics.Ariana Buscigliopptx
 
Multithreading_in_C++ - std::thread, race condition
Multithreading_in_C++ - std::thread, race conditionMultithreading_in_C++ - std::thread, race condition
Multithreading_in_C++ - std::thread, race condition
 
Lapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdfLapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdf
 
Supporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptxSupporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptx
 
Embracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic ImperativeEmbracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic Imperative
 
Francesca Gottschalk - How can education support child empowerment.pptx
Francesca Gottschalk - How can education support child empowerment.pptxFrancesca Gottschalk - How can education support child empowerment.pptx
Francesca Gottschalk - How can education support child empowerment.pptx
 
Digital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and ResearchDigital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and Research
 
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
 
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
 
Language Across the Curriculm LAC B.Ed.
Language Across the  Curriculm LAC B.Ed.Language Across the  Curriculm LAC B.Ed.
Language Across the Curriculm LAC B.Ed.
 
Unit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdfUnit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdf
 
Marketing internship report file for MBA
Marketing internship report file for MBAMarketing internship report file for MBA
Marketing internship report file for MBA
 
Normal Labour/ Stages of Labour/ Mechanism of Labour
Normal Labour/ Stages of Labour/ Mechanism of LabourNormal Labour/ Stages of Labour/ Mechanism of Labour
Normal Labour/ Stages of Labour/ Mechanism of Labour
 
The French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free downloadThe French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free download
 
Model Attribute Check Company Auto Property
Model Attribute  Check Company Auto PropertyModel Attribute  Check Company Auto Property
Model Attribute Check Company Auto Property
 
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
 

Static arrays are structures whose size is fixed at compile time and.pdf

  • 1. Static arrays are structures whose size is fixed at compile time and therefore cannot be extended or reduced to fit the data set. A dynamic array can be extended by doubling the size but there is overhead associated with the operation of copying old data and freeing the memory associated with the old data structure. One potential problem of using arrays for storing data is that arrays require a contiguous block of memory which may not be available, if the requested contiguous block is too large. However the advantages of using arrays are that each element in the array can be accessed very efficiently using an index. However, for applications that can be better managed without using contiguous memory we define a concept called “linked lists”. A linked list is a collection of objects linked together by references from one object to another object. By convention these objects are named as nodes. So the basic linked list is collection of nodes where each node contains one or more data fields AND a reference to the next node. The last node points to a NULL reference to indicate the end of the list. Types of Linked Lists Linked lists are widely used in many applications because of the flexibility it provides. Unlike arrays that are dynamically assigned, linked lists do not require memory from a contiguous block. This makes it very appealing to store data in a linked list, when the data set is large or device (eg: PDA) has limited memory. One of the disadvantages of linked lists is that they are not random accessed like arrays. To find information in a linked list one must start from the head of the list and traverse the list sequentially until it finds (or not find) the node. Another advantage of linked lists over arrays is that when a node is inserted or deleted, there is no need to “adjust” the array. There are few different types of linked lists. A singly linked list as described above provides access to the list from the head node. Traversal is allowed only one way and there is no going back. A doubly linked list is a list that has two references, one to the next node and another to previous node. Doubly linked list also starts from head node, but provide access both ways. That is one can traverse forward or backward from any node. A multilinked list (see figures 1 & 2) is a more general linked list with multiple links from nodes. For examples, we can define a Node that has two references, age pointer and a name pointer. With this structure it is possible to maintain a single list, where if we follow the name pointer we can traverse the list in alphabetical order of names and if we traverse the age pointer, we can traverse the list sorted by ages. This type of node organization may be useful for maintaining a customer list in a bank where same list can be traversed in any order (name, age, or any other criteria) based on the need. Designing the Node of a Linked List Linked list is a collection of linked nodes. A node is a struct with at least a data field and a reference to a node of the same type. A node is called a self-referential object, since it contains a
  • 2. pointer to a variable that refers to a variable of the same type. For example, a struct Node that contains an int data field and a pointer to another node can be defined as follows. typedef struct node { int data; struct node* next; } node; node* head = NULL; Creating the first node Memory must be allocated for one node and assigned to head as follows. head = (node*) malloc(sizeof(node)); headdata = 10; headnext = NULL; Adding the second node and linking node* nextnode = malloc(sizeof(node)); nextnodedata = 12; nextnodenext = NULL; headnext = nextnode; Linked list is a data structure in which the items are ordered in a linear way. Although modern programming languages support very flexible and rich libraries that works with arrays, which use arrays to represent lists, the principles of building a linked list remain very important. The way linked lists are implemented is a ground level in order to build more complex data structures such as trees. It’s true that almost every operation we can perform on a linked list can be done with an array. It’s also true that some operations can be faster on arrays compared to linked lists. However understanding how to implement the basic operations of a linked list such as INSERT, DELETE, INSERT_AFTER, PRINT and so on is crucial in order to implement data structures as rooted trees, B-trees, red-black trees, etc. Big-O notation is a way to express the efficiency of an algorithm. If you’re going to be working with code, it is extremely important that you understand Big-O. It is, quite literally, the language we use to express efficiency. Big-O is an expression of how the execution time of a program scales with the input data. That is, as the input gets bigger, how much longer will the program take? Just a little bit? A lot longer? Suppose you have a function for which does some processing on an array of size N. If foo takes O(N) time, then, as the array grows (that is, as N increases), the number of seconds foo takes will also increase in some sort of linear fashion.
  • 3. The first decision in planning the linked-list implementation of the Queue class is which end of the list will correspond to the front of the queue. Recall that items need to be added to the rear of the queue, and removed from the front of the queue. Therefore, we should make our choice based on whether it is easier to add/remove a node from the front/end of a linked list. If we keep pointers to both the first and last nodes of the list, we can add a node at either end in constant time. However, while we can remove the first node in the list in constant time, removing the last node requires first locating the previous node, which takes time proportional to the length of the list. Therefore, we should choose to make the end of the list be the rear of the queue, and the front of the list be the front of the queue. Other than saving space, the first advantage I can see for singly linked lists over doubly linked lists is to avoid having to update two links instead of one when you modify the list, when adding an element for example. Of course, one might say that you can always ignore the second link, but in that case, it is no longer doubly linked, but only an unused field.What might also be seen as an advantage is that singly linked list are necessarily consistent, though possibly wrong when there are bugs in the program. Doubly linked lists can end-up having inconsistent links forward and backward. But it is debatable which of the two cases, if any, is an advantage. update: I had tried to see some impact on garbage collection, but found none. Actually, there is one when storage reclamation is done by reference counting, as reference counting is defeated by loops, and doubly linked lists contain loops. Singly linked list escape the problem. Of course, there are ways around it for doubly linked lists, such as the use of weak pointers, or programmable reference counting as part of data abstraction. Solution Static arrays are structures whose size is fixed at compile time and therefore cannot be extended or reduced to fit the data set. A dynamic array can be extended by doubling the size but there is overhead associated with the operation of copying old data and freeing the memory associated with the old data structure. One potential problem of using arrays for storing data is that arrays require a contiguous block of memory which may not be available, if the requested contiguous block is too large. However the advantages of using arrays are that each element in the array can be accessed very efficiently using an index. However, for applications that can be better managed without using contiguous memory we define a concept called “linked lists”. A linked list is a collection of objects linked together by references from one object to another object. By convention these objects are named as nodes. So the basic linked list is collection of
  • 4. nodes where each node contains one or more data fields AND a reference to the next node. The last node points to a NULL reference to indicate the end of the list. Types of Linked Lists Linked lists are widely used in many applications because of the flexibility it provides. Unlike arrays that are dynamically assigned, linked lists do not require memory from a contiguous block. This makes it very appealing to store data in a linked list, when the data set is large or device (eg: PDA) has limited memory. One of the disadvantages of linked lists is that they are not random accessed like arrays. To find information in a linked list one must start from the head of the list and traverse the list sequentially until it finds (or not find) the node. Another advantage of linked lists over arrays is that when a node is inserted or deleted, there is no need to “adjust” the array. There are few different types of linked lists. A singly linked list as described above provides access to the list from the head node. Traversal is allowed only one way and there is no going back. A doubly linked list is a list that has two references, one to the next node and another to previous node. Doubly linked list also starts from head node, but provide access both ways. That is one can traverse forward or backward from any node. A multilinked list (see figures 1 & 2) is a more general linked list with multiple links from nodes. For examples, we can define a Node that has two references, age pointer and a name pointer. With this structure it is possible to maintain a single list, where if we follow the name pointer we can traverse the list in alphabetical order of names and if we traverse the age pointer, we can traverse the list sorted by ages. This type of node organization may be useful for maintaining a customer list in a bank where same list can be traversed in any order (name, age, or any other criteria) based on the need. Designing the Node of a Linked List Linked list is a collection of linked nodes. A node is a struct with at least a data field and a reference to a node of the same type. A node is called a self-referential object, since it contains a pointer to a variable that refers to a variable of the same type. For example, a struct Node that contains an int data field and a pointer to another node can be defined as follows. typedef struct node { int data; struct node* next; } node; node* head = NULL; Creating the first node Memory must be allocated for one node and assigned to head as follows. head = (node*) malloc(sizeof(node)); headdata = 10;
  • 5. headnext = NULL; Adding the second node and linking node* nextnode = malloc(sizeof(node)); nextnodedata = 12; nextnodenext = NULL; headnext = nextnode; Linked list is a data structure in which the items are ordered in a linear way. Although modern programming languages support very flexible and rich libraries that works with arrays, which use arrays to represent lists, the principles of building a linked list remain very important. The way linked lists are implemented is a ground level in order to build more complex data structures such as trees. It’s true that almost every operation we can perform on a linked list can be done with an array. It’s also true that some operations can be faster on arrays compared to linked lists. However understanding how to implement the basic operations of a linked list such as INSERT, DELETE, INSERT_AFTER, PRINT and so on is crucial in order to implement data structures as rooted trees, B-trees, red-black trees, etc. Big-O notation is a way to express the efficiency of an algorithm. If you’re going to be working with code, it is extremely important that you understand Big-O. It is, quite literally, the language we use to express efficiency. Big-O is an expression of how the execution time of a program scales with the input data. That is, as the input gets bigger, how much longer will the program take? Just a little bit? A lot longer? Suppose you have a function for which does some processing on an array of size N. If foo takes O(N) time, then, as the array grows (that is, as N increases), the number of seconds foo takes will also increase in some sort of linear fashion. The first decision in planning the linked-list implementation of the Queue class is which end of the list will correspond to the front of the queue. Recall that items need to be added to the rear of the queue, and removed from the front of the queue. Therefore, we should make our choice based on whether it is easier to add/remove a node from the front/end of a linked list. If we keep pointers to both the first and last nodes of the list, we can add a node at either end in constant time. However, while we can remove the first node in the list in constant time, removing the last node requires first locating the previous node, which takes time proportional to the length of the list. Therefore, we should choose to make the end of the list be the rear of the queue, and the front of the list be the front of the queue. Other than saving space, the first advantage I can see for singly linked lists over doubly linked lists is to avoid having to update two links instead of one when you modify the list, when adding
  • 6. an element for example. Of course, one might say that you can always ignore the second link, but in that case, it is no longer doubly linked, but only an unused field.What might also be seen as an advantage is that singly linked list are necessarily consistent, though possibly wrong when there are bugs in the program. Doubly linked lists can end-up having inconsistent links forward and backward. But it is debatable which of the two cases, if any, is an advantage. update: I had tried to see some impact on garbage collection, but found none. Actually, there is one when storage reclamation is done by reference counting, as reference counting is defeated by loops, and doubly linked lists contain loops. Singly linked list escape the problem. Of course, there are ways around it for doubly linked lists, such as the use of weak pointers, or programmable reference counting as part of data abstraction.