text: out by ptr. i.e., NEW.LINK = ptr.LINK b) Place the data X in the DATA field of the NEW node. i.e., NEW.DATA = X c) Now make the LINK field of the ptr node to point the NEW node. ptr.LINK=NEW 4. EXIT Insertion of a Node at any position(contd..) 18 Visiting each node in the singly linked list starting from the first node to/
  ==tail) tail=pred; }}}} addToHead() and addToTail() can be executed in constant time O(1), ie regardless of no.of nodes, the no.of operations performed by these two methods does not exceed some constant number c. When we attempt to remove a node from an empty list, the pgm crashes because of NullPointerException. Singly Linked List There are two ways of solving this problem. One solution/
  c) and 19. 3 (c) of R 1260/99) II. Cohesion Fund: The need for a co-ordinated approach with Structural Funds The Cohesion Fund: Programming and link/ objectives Priorities Selection criteria List of priority projects Estimated cost including financial plan The implementation timetable The Cohesion Fund: Programming and link to the Structural Funds / in the same area or corridor z overall plan z supervised by a single body III. Cohesion Fund: Project submissions (1) The Cohesion Fund: Programming and link/
  () { return next; public Object getData() { return data; public void setNext(SListNode n) { public void setData(Object d) { Each node is a “link” in a chain of “nodes”. Each node can only see “forward”. Each node contains a data element. Singly Linked List class SinglyLinkedList implements List{ private SListNode head; private int size; SinglyLinkedList() { head = null; size = 0; } public void addToFront(Object o) { … public void addToTail(Object/
  methods a.boolean add( Object x) -- append to end of the list b.boolean add(int i, Object x) – insert at position i c.boolean remove(int i) – remove object at position i 3.Singly Linked List -- outline of methods 4.Circularly Linked List Linked Lists A LinkedList implements the interface List There are a number of ways in which a LinkedList can be implemented internally, but each implementation should provide/
  in this single trailing pointer example illustrated here, not 23), this line of code deletes it start 37 5 23 -2 The code above covers all the bases delPtr Linked Lists Traversal and Traversal-Based Operations Introduction and Motivation Building (Insertion Into) a Linked List/, the compiler is happy to generate the code to do the evaluations and make the assignment delPtr Last Sidebar: C is Being Nice to Us for a Change delPtr->next->previous = delPtr->previous Got it? OK, then how about/
  What is the advantage/disadvantage of the singly linked representation in terms of read/update values and insertion/deletion of nodes? Linked List Implementation of Singly Linked List listPointer create(){ return (listPointer)NULL; } Boolean IsEmptyL(listPointer l){ if (l == NULL) return TRUE; else return FALSE; } int main() { listPointer l; l = create(); ... NULL is used as 0 meaning empty and false in C language. NULL does not have a type. (ListPointer/
  1.5n Therefore T(n) is O(n2) when n0 is 1 and c is 1.5 Big-O Example 2 (cont.) Symbols Used in Quantifying Performance Common Growth Rates Different Growth Rates Effects of Different Growth Rates Exponential// true; } Double-Linked Lists and Circular Lists Section 2.6 Limitations of Single-Linked Lists Insertion front is O(1) other positions is O(n) Removing requires a reference to the previous node Traversing Only in one direction What is the solution ? Double-Linked Lists Example Node Class Definition/
  , so the cost per item is O(1) Both linked-list implementations require more storage because extra space is required for links Comparing the Three Implementations (cont.) C++ stores a copy of the data for a queue element in each node in addition to the links a node in a single linked list stores a total of one pointer a node in a double-linked list stores a total of two pointers a node/
  struct Node { int item; struct Node *pn; /* Valid */ }; 14 15 Example: A Linked List Linked lists come in two basic varieties: singly linked and doubly linked. We describe here a simple version of a singly linked list. List consists of a set of nodes, where each node contains an item and a pointer to another list node. struct List { int item; struct List *next; }; (Here we have chosen an int as the contained item. Any/
  : Confidentiality/Privacy Authentication Integrity Limiting data access Kinds of encryption in networks: Link encryption vs. end-to-end (e2e) encryption Virtual private/scenario (handshake protocol) C requests an SSL session by sending: Hello-C, Rand-C (random nr), list of cipher (encryption) algorithms & hash algorithms known to C Hash used to checksum/ level More expensive / more difficult to configure Software firewalls Used in single workstations Less expensive / Easier to configure d. Types of firewalls/ /
  Single-Linked List to Implement a Queue Insertions are at the rear of a queue and removals are from the front We need a reference to the last list node so that insertions can be performed at O(1) The number of elements in/ = size – 1; private void reallocate() { int/
  4-4 Singly-linked-lists (1) A singly-linked-list (SLL) consists of a header together with a sequence of nodes connected by links in one direction only: –Each SLL node contains a single element, plus a link to the /in a linked-list. Four cases to consider: A.insertion in an empty linked-list; B.insertion before the first node of a non-empty linked- list; C.insertion after the last node of a non-empty linked-list; D.insertion between nodes of a non-empty linked-list. The insertion algorithm needs links/
  of nodes, connected by links in one direction only. Each SLL node contains a single element, plus a link to the node’s successor (or a null link if the node has no successor). A SLL header contains a link to the SLL’s first node (or a null link if the SLL is empty). pigdogratcatdog Prof A Alkhorabi 4- 21 Singly-linked lists (2) A C++ structure is used to/
  has to be traversed. The cost is therefore O(n). Characteristics of Linked Lists Advantages of linked lists: Dynamic nature of the data structure Flexible structure –singly linked lists –doubly linked –circular lists –etc., etc. Characteristics of Linked Lists Disadvantages of linked lists: Linear worst-case cost of access The absence of a Linked List implementation in standard C libraries Programming Linked Lists The dynamic nature of the data structure means we must allocate and free memory – malloc() to/
  wait ARQ) S Y N S O H S T X E T X B C C Header …Data… Multiblock frame Reason to divided into blocks ITB = Intermediate text block/damage, loss or duplication). It is performed end to end rather than across a single link. In the data link layer, the term error control refers primarily to methods of error detection and retransmission/for the exchange of network management information VCC Characteristics ITU-T recommendation I.150 lists the following as characteristics of VCCs Quality of Service A user of a VCC/
  98 a) dlist head 7611 -21 b) sentinel dlist head 11 -21 c) Introduction (cont’d) We show below some empty doubly lists. Doubly linked lists require more memory space than singly linked lists. Doubly linked lists are useful in many applications. Head tail Head sentinel Doubly Linked Lists: Implementation The java class Doubly Linked Lists defines the proposed implementation of Doubly linked lists. COE Ali Juma’ah 987458 Student EE Saleh Fouad 201547 Student dlist/
  / z; 7 printf (“%f”,z); 119 Bubble Sort Algorithm 1234567 1 for (j=1; j list[k+1]) { temp = list[k]; list[k] = list[k+1]; list[k+1] = temp; 4 } 5 } 6 } 7 print(“Done ”); 120 Paths A /smallest segment is a link. A link is a single process that lies between 2 nodes. 121 Paths (Cont’d) The length of a path is the number of links in a path. An entry/ some test. Clearly, AU < ADUP. 222 All p-uses/Some c-uses Strategy (APU+C) APU+C requires that for every variable and every definition of that variable include at/
  in the Queue interface for insertion ( offer and add ), removal ( remove and poll ), and for accessing the element at the front ( peek and element ) To understand how to implement the Queue interface using a single-linked list, a circular array, and a double-linked list /
  T(n) is O(n2) when n0 is 1 and c is 1.5 Big-O Example 2 (cont.) Symbols Used in Quantifying Performance Common Growth Rates Different Growth Rates Effects of Different /Single-Linked Lists Section 2.5/
  , we can replace the array with a larger one How large should the new array be? incremental strategy: increase the size by a constant c doubling strategy: double the size Algorithm push(o) if t = S.length 1 then A new array of size … for i/ 1], …, V[n 1] In the worst case ( r 0 ), this takes O(n) time V 012n r V 012n o r V 012n r Lists and Sequences Elementary Data Structures36 Outline and Reading Singly linked list Position ADT and List ADT (§2.2.2) Doubly linked list (§ 2.2.2) Sequence ADT (§/
  In Section on OS Security Many of these strategies are useful for network security b. Security threat analysis (1) Threat analysis steps : 1) Analyze system components and their interactions 2) Analyze possible damage to C-I-A 3) Hypothesize possible kinds of attacks Network elements to be considered: Local elements Nodes / comm links/ protocol More - see bulleted list on p. 464 (iii) Personal firewalls Regular firewalls protects subnetworks Personal firewalls protect single hosts For small business / /
  obvious simplicity, there are myriad implementation variations. The figure below shows several of the most common singly-linked list variants. head (a) tail (d) head sentinel (c) head tail (b) 20 Lecture 25 Linked List (Cont’d) The basic singly-linked list is indicated in the above figure by (a). Each element of the list refers to its successor and the last element contains the null reference. One variable, labeled head/
  K+W Chap 4.1-4.5, 2.6 Collection add(x) remove(x) member(x) size() first() Single Linked List Class Exercise Implement add, member, first Efficiency of Algorithms An operation for our ADT can be thought of as / 25 T(n) = O(f(n)) means that there exists a function, f(n), that for sufficiently large n and some constant c: cf(n) T(n) n 2 + 25n + 25 vs. 3n 2 Common Big-O Runtimes Constant -- O(1) Logarithmic/ (cont’) Class Exercise Implement last on our Linked List Group Exercise Implement last in O(1)
  node from a list RemoveNode: remove a node from a list SearchNode: search a node in a list SearchNode: search a node in a list CountNodes: compute the length of a list CountNodes: compute the length of a list PrintContent: print the content of a list PrintContent: print the content of a list … Singly Linked List 16 Count a linked list: Use a pointer p to traverse the list first …… p //List.cpp int List::Count() { int result/
  : Removal of an element at the head of a singly linked list: (a) before the removal; (b) "linking out" the old new node; (c) after the removal. Removing an Element in a Singly Linked List Code Fragment 3.16: Removing the node at the beginning of a singly linked list. Removing an Element in a Singly Linked List Unfortunately, we cannot easily delete the tail node of a singly linked list. Even if we have a tail reference directly/
  ’) linked lists are: LIFO (last in – first out) also called a stack FIFO (first in – first out) also called a queue Singly linked lists An ordered collection of data in which each element contains the location of the next element Singly Linked lists Element or node pList=null Pointer Head next Head Linked lists Record/ PARENT to LEFT CHILD, then to NEXT SIBLING.. Then each node has AT MOST 2 edges going out A B C D E F G H Re-arrange the child sibling into an equivalent tree of binary form R CZ TKA N/
  pointer to the next term. Declarations typedef struct poly_node *poly_pointer; typedef struct poly_node { int coef; int expon; poly_pointer link; }; poly_pointer a, b, c; coef expon link -Polynomial representation 3 14 2 8 1 0 a null 8 14 -3 10 10 6 b null 4.4.2/ ptr =3X 14 +2X 8 +1 1438201 ptr Chain: A singly linked list in which the last node has a null link. Nodes that are no longer in use are freed so that we can reuse these nodes later. Maintaining a list (as a chain) of nodes that have been “ freed ”. /
  much easier Q4: –What if you reverse all the links? (reversed single linked list) With head pointer only? With both head and tail pointers? 10 Midterm Test Tips Analyzing the topics: –C/C++: Likely used as part of question in the essay But may appear as standalone question in MCQ –ADT: Likely embedded in Linked List/Stack/Queue question in essay –List ADT: Vector versus Linked List idea, we spend two weeks here, most likely/
  ( * ): What can you dereference? – Anything that is of pointer type. Example of using pointers to pointers: – Suppose you have a singly linked list [interactive]: struct Node { int value; Node *next; }; Node *head = 0; – One way to append to it: Node *end /f(int i, double) { … } – Why might this ever happen? Ellipses void foo(const char *, …); – Need one parameter in C, but not in C++. Use. Example: – #include #include void print_strings(const char *s0,...) { printf("%s ", s0); va_list ap; va_start(ap, s0/
  )Update head to point to next node in the list c)Allow garbage collector to reclaim the former first node EECS2011: Arrays & Linked Lists 27 Last Update: Aug 21, 2014 Java Method EECS2011: Arrays & Linked Lists 28 Last Update: Aug 21, 2014 Removing at the Tail Removing at the tail of a singly linked list is not efficient! It’s impossible in constant-time to access the predecessor of the tail/
  -tree mode pvst spanning-tree extend system-id ! vlan internal allocation policy ascending ! interface FastEthernet0/1 description "Link to Moscow" switchport mode access switchport port-security switchport port-security maximum 1 switchport port-security mac-address sticky / allowed 111T-110.5101 Cisco IOS - (c) Jere Mäkelä ACL (20/24) Named ACLs You can delete a single entry in a named ACL without deleting the whole ACL Router(config)#ip access-list standard|extended ACL_name This command takes you into/
  host, R n = router 93 An internetwork is a network of networks in the figure, we see Ethernets, an FDDI ring, and a point-to-point link each of these is a single-technology network the nodes that interconnect the networks are called routers (sometimes called / list is empty, stop. Otherwise, pick the entry from the Tentative list with the lowest cost, move it to the Confirmed list, and return to step 2 247 Example Link-state routing: an example network (B, 11, B) (C, 2, C) (B, 5, C) (A, 12, C) (A, 10, C)/
  a TCP connection to the Service_Reporter object The Service_Reporter returns a list of all the servers services to the client The Service_Reporter closes / 4 get_opt.long_option (ACE_TEXT ("port"), 5 p, ACE_Get_Opt::ARG_REQUIRED); 6 for (int c; (c = get_opt ()) != -1;) 7 if (c == p) local_addr.set_port_number 8 (ACE_OS::atoi (get_opt.opt_arg ())); 9 acceptor_.open (/be connected in an arbitrary order If client is establishing connections over high latency links If client is a single-threaded applications/
  last octet is the VRID Virtual Router Redundancy Protocol Overview ! VRRP is a gateway redundancy protocol designed to prevent from a single point failure when the default gateway fails. Virtual MAC Address (M) VRID 1 / IP addr (S) VRID 1 // by sending back an IGMPv3 membership report that contains their specific multicast address list for the interface. Multicast in D-Link Switching Environment Internet Group Multicast Protocol Version 3 AB C Client-1 Report Multicast Server-1 Source IP: 192.168.0.1/24/ /
  this disk can hold up to 17 gigabytes. The current version, which is single layer, single sided holds 4.7 gigabytes. Since this technology is still relatively new, there are/then click Search. 3. A list of search results is displayed in the Search window. Click any link in the list to display that Web page in the right side of the browser /Compression) Solid State Power Amplifier (SSPA) is available as an option. The PES C-band incorporates a 5-watt SSPA. Both the receiver and the transmitter are stabilized /
  the CPU running all the time) Scheduling queues Ready queue (usually a linked list): the processes that are in the main memory and ready to be executed Device queue: the list of processes waiting for a particular IO device FIG 4.4 66 Process / with no kernel’s support Advantage: fast Disadvantage: if a kernel is single-threaded, any user-level thread -> blocking system calls => block the entire process POSIX Pthreads, Mach C-threads, Solaris threads 87 User and Kernel Threads Kernel threads Supported by the/
  Journal (general journal) - contains a chronological list of the transactions entered into by a company, usually in journal entry form. a. Enter date of transaction. b. List the accounts to be debited/credited. c. Include the dollar amounts of debits/credits. /c.) The retirement of the bonds on the maturity date c.) The retirement of the bonds on the maturity date LinkLink to Excel worksheet with Solutions to Class Problem Link Chapter 1-186 Future value of a single present amount Present value of a single/
  linked-list of nodes in a dlB Only pointers that are used are in the list –Any pointers that are not used are not included in the list For lower levels this will save an incredible amount dlB nodes are uniform with two references each One for sibling and one for a single/ But, for many practical applications, we can restrict TSP as follows: For each distance in the graph: d(c I,c J ) <= d(c I,c K ) + d(c K,c J ) –TRIANGLE INEQUALITY > A direct path between two vertices is always the shortest Given this/
  6. AC 0.5 A F ABDEF C ABDEF..5 C.5. E 0.9 0.8 B D C 0.6 0.5 Single Link Clustering (Cont.) Single-Link Clusters Similarity level 0.7 (i.e., similarity threshold) ◦ ABEF ◦ C ◦ D Similarity level 0.5 (i./to remember the list of all item pairs previously considered in the clustering process. Comparison ◦ The complete-link clustering system may be better adapted to retrieval than the single-link clusters. ◦ A complete-link cluster generation is more expensive to perform than a comparable single-link process. D i/
  (" The elements in reverse order: "); while(ptr!=header) { if(ptr->next==NULL) printf(" %d",ptr->data); else printf(" %d",ptr->data); ptr=ptr->prev; }/* end of while */ printf(" %d",ptr->data); }/* end of else */ }/* end of traverse() */ Circular linked list The linked list where the last node points the header node is called circular linked list. Circular singly linked list Circular doubly linked list /* Write a c program to implement circular linked list*/ #include #include/
  error key */ *front = (*front + 1) % MAX_QUEUE_SIZE; return queue[*front]; } deleteq(&front, rear) Networking Laboratory 70/78 Algorithms Lists Networking Laboratory 71/78 Algorithms Singly Linked Lists Compose of data part and link part Link part contains address of the next element in a list Non-sequential representations Size of the list is not predefined Dynamic storage allocation and deallocation batsatcatvat NULL ptr Networking Laboratory 72/78 Algorithms Insertion of/
  A->C TOWER(1,B,A,C) -------------------B->C TOWER(2,B,C,A) ----------------------------------B->A TOWER(1,C,B,A) --------------------C->A TOWER(3,B,A,C)---------------------------------------------------------B->C TOWER(1,A,C,B) ------------------- A-> B TOWER(2,A,B,C) ------------------------------------A->C TOWER(1,B,A,C) --------------------B->C Operations on Graph Suppose a graph G is maintained in memory by the linked list representation GRAPH(NODE,NEXT,ADJ,START,AVAILN,DEST,LINK,AVAIL/
  + 25 Find the point where cn 2 = n 2 + 5n + 25 Let n = n 0, and solve for c c = 1 + 5/ n 0, + 25/ n 0 2 When n 0 is 5, c = (1 + 5/5 + 25/25) = 3 So, 3n 2 > n 2 + 5n + 25 for all n/?), /
  to store size in each list (4 bytes) – adds c units of time to each insert/erase In our data structures we calculate size – C++ compiler vendors allowed to do it either way for std::list, so don’t assume anything! 14 if (list.size() == 0) cout << "empty list"; if (list.empty()) cout << "empty list"; vs Circular Singly Linked List in C++ How do we want to use a linked list?... How might this look in memory? 15/
  &Node2 ; // … or that way! Statically vs Dynamically allocated memory C provides for support of a logical (ie. conceptual) model in which user allocated memory (for a given program) is divided into several /malloc( NodeSize ) ; fread( NodePtr, PayloadSize, 1, cfPtr ) ; \ Logic to find where to insert this inputted data block \ in the singly linked list. } Pointer NodePtr Data Linked lists \ ASSUMPTION: File has been opened using cfPtr while( ! feof( cfPtr ) ) { NodePtr = malloc( NodeSize ) ; fread( NodePtr,/
  Data Structures and Algorithms Fall2009 Quratulain 11 Singly-linked lists Here is a singly-linked list: Each node contains a value and a link to its successor (the last node has no successor) The header points to the first node in the list (or contains the null link if the list is empty) abcd myList CSE 246 Data Structures and Algorithms Fall2009 Quratulain 12 Singly-linked lists in Java public class SLinkList { Private node start/
  one How large should the new array be? –incremental strategy: increase the size by a constant c –doubling strategy: double the size Let n = current number of elements in array N = capacity of array Algorithm add(o) if n = N then A new array/ ADT takes O(1) time t nodes elements Implementing a Queue with a Singly-Linked List Just as for stacks, queue implementations can be based upon either arrays or linked lists. In a linked list implementation: –The front element is stored at the first node –The rear /