malloc(), calloc(), realloc(), and free()

Size: px
Start display at page:

Download "malloc(), calloc(), realloc(), and free()"

Transcription

1 1 next CITS2002 CITS2002 schedule Dynamic data structures Initially, we focused on scalar and array variables, whose size is known at compile-time. More recently, we've focused on arrays of values, whose required size was only known at run-time. In the case of dynamic arrays we've used C99 functions such as: to manage the required storage for us. malloc(), calloc(), realloc(), and free() An extension to this idea is the use of dynamic data structures - collections of data whose required size is not known until run-time. Again, we'll use C99's standard memory allocation functions whenever we require more memory. However, unlike our use of realloc to grow (or shrink) a single data structure (there, an array), we'll see two significant differences: we'll manage a complete data structure by allocating and deallocating its "pieces", and we'll keep all of the "pieces" linked together by including, in each piece, a "link" to other pieces. To implement these ideas in C99, we'll develop data structures that contain pointers to other data structures. CITS2002 Systems Programming, Lecture 19, p1, 8th October 2018.

2 prev 2 next CITS2002 CITS2002 schedule A simple dynamic data structure - a stack We'll commence with a simple stack - a data structure that maintains a simple list of items by adding new items, and removing existing items, from the head of the list. Such a data structure is also termed a first-in-last-out data structure, a FILO, because the first item added to the stack is the last item removed from it (not the sort of sequence you want while queueing for a bank's ATM!). Let's consider the appropriate type definition in C99: typedef struct _s int value; struct _s *next; STACKITEM; STACKITEM *stack = NULL; Of note: we haven't really defined a stack datatype, but a single item that will "go into" the stack. the datatype STACKITEM contains a pointer field, named next, that will point to another item in the stack. we've defined a new type, a structure named _s, so that the pointer field next can be of a type that already exists. we've defined a single pointer variable, named stack, that will point to a stack of items. CITS2002 Systems Programming, Lecture 19, p2, 8th October 2018.

3 prev 3 next CITS2002 CITS2002 schedule Adding items to our stack data structure As a program's execution progresses, we'll need to add and remove data items from the data structure. The need to do this is not known until run-time, and data (perhaps read from file) will determine how large our stack eventually grows. As its name suggests, when we add items to our stack, we'll speak of pushing new items on the stack, and popping existing items from the stack, when removing them. typedef struct _s int value; struct _s *next; STACKITEM; STACKITEM... *stack = NULL; // same definition as before void push_item(int newvalue) STACKITEM *new = malloc( sizeof(stackitem) ); if(new == NULL) // check for insufficient memory perror( func ); new->value new->next stack = newvalue; = stack; = new; The functions push_item and pop_item are quite simple, but in each case we must worry about the case when the stack is empty. We use a NULL pointer to represent the condition of the stack being empty. CITS2002 Systems Programming, Lecture 19, p3, 8th October 2018.

4 prev 4 next CITS2002 CITS2002 schedule Removing items from our stack data structure The function pop_item now removes an item from the stack, and returns the actual data's value. In this example, the data held in each STACKITEM is just a single integer, but it could involve several fields of data. In that case, we may need more complex functions to return all of the data (perhaps using a structure or pass-by-reference parameters to the pop_item function). Again, we must ensure that we don't attempt to remove (pop) an item from an empty stack: int pop_item(void) STACKITEM *old; int oldvalue; if(stack == NULL) fprintf(stderr, "attempt to pop from an empty stack\n"); oldvalue old stack free(old); return oldvalue; = stack->value; = stack; = stack->next; CITS2002 Systems Programming, Lecture 19, p4, 8th October 2018.

5 prev 5 next CITS2002 CITS2002 schedule Printing our stack data structure To print out our whole data structure, we can't just use a standard C99 function as C99 doesn't know/understand our data structure. Thus we'll write our own function, print_stack, to traverse the stack and successively print each item, using printf. Again, we must check for the case of the empty stack: void print_stack(void) STACKITEM *thisitem = stack; while(thisitem!= NULL) printf("%i", thisitem->value); thisitem = thisitem->next; if(thisitem!= NULL) printf(" -> "); if(stack!= NULL) printf("\n"); Again, our stack is simple because each node only contains a single integer. If more complex, we may call a different function from within print_stack to perform the actual printing:... print_stack_item( thisitem ); CITS2002 Systems Programming, Lecture 19, p5, 8th October 2018.

6 prev 6 next CITS2002 CITS2002 schedule Using our stack in a Reverse Polish Calculator Let's employ our stack data structure to evaluate basic integer arithmetic, as if using a Reverse Polish Calculator. Each integer read from lines of a file is pushed onto the stack, arithmetic operators pop 2 integers from the stack, perform some arithmetic, and push the result back onto the stack. int evaluate_rpn(file *fp) char line[bufsiz]; int val1, val2; while( fgets(line, sizeof(line), fp)!= NULL ) if(line[0] == '#') continue; if(isdigit(line[0]) line[0] == '-') push_item( atoi(line) ); else if(line[0] == 'a') val1 = pop_item(); val2 = pop_item(); push_item( val1 + val2 );... else if(line[0] == 'd') val1 = pop_item(); val2 = pop_item(); push_item( val2 / val1 ); else break; return pop_item(); # Our input data: 12 3 add 5 div CITS2002 Systems Programming, Lecture 19, p6, 8th October 2018.

7 prev 7 next CITS2002 CITS2002 schedule Using our stack in a Reverse Polish Calculator, continued Careful readers may have noticed that in some cases we don't actually need the integer variables val1 and val2. We can use the 2 results returned from pop_item as arguments to push_item: int evaluate_rpn(file *fp) char line[bufsiz]; while( fgets(line, sizeof line, fp)!= NULL ) if(line[0] == '#') continue; if(isdigit(line[0]) line[0] == '-') push_item( atoi(line) ); else if(line[0] == 'a') push_item( pop_item() + pop_item() );... return pop_item(); int main(int argc, char *argv[]) printf("%i\n", evaluate_rpn( stdin ) ); return 0; CITS2002 Systems Programming, Lecture 19, p7, 8th October 2018.

8 prev 8 next CITS2002 CITS2002 schedule Problems with our stack data structure As written, our stack data structure works, but may be difficult to deploy in a large program. In particular, the whole stack was represented by a single global pointer variable, and all functions accessed or modified that global variable. What if our program required 2, or more, stacks? What if the required number of stacks was determined at run-time? Could the stacks be manipulated by functions that didn't actually "understand" the data they were manipulating? Ideally we'd re-write all of our functions, push_item, push_item, and print_stack so that they received the required stack as a parameter, and used or manipulated that stack. Techniques on how, and why, to design and implement robust data structures are a focus of the unit CITS2200 Data Structures & Algorithms. CITS2002 Systems Programming, Lecture 19, p8, 8th October 2018.

9 prev 9 next CITS2002 CITS2002 schedule Declaring a list of items Let's develop a similar data structure that, unlike the first-in-last-out (FILO) approach of the stack, provides first-in-first-out (FIFO) storage - much fairer for queueing at the ATM! We term such a data structure a list, and its datatype declaration is very similar to our stack: typedef struct _l char *string; struct _l *next; LISTITEM; LISTITEM *list = NULL; As with the stack, we'll need to support empty lists, and will again employ a NULL pointer to represent it. This time, each data item to be stored in the list is string, and we'll often term such a structure as "a list of strings". CITS2002 Systems Programming, Lecture 19, p9, 8th October 2018.

10 prev 10 next CITS2002 CITS2002 schedule Adding (appending) a new item to our list When adding (appending) new items to our list, we need to be careful about the special (edge) cases: the empty list, and when adding items to the end: void append_item(char *newstring) if(list == NULL) // append to an empty list list = malloc( sizeof(listitem) ); if(list == NULL) perror( func ); list->string = strdup(newstring); list->next = NULL; else // append to an existing list LISTITEM *p = list; while(p->next!= NULL) // walk to the end of the list p = p->next; p->next = malloc( sizeof(listitem) ); if(p->next == NULL) perror( func ); p = p->next; // append after the last item p->string = strdup(newstring); p->next = NULL; Notice how we needed to traverse the whole list to locate its end. Such traversal can become expensive (in time) for very long lists. CITS2002 Systems Programming, Lecture 19, p10, 8th October 2018.

11 prev 11 next CITS2002 CITS2002 schedule Removing an item from the head our list Removing items from the head of our list, is much easier. Of course, we again need to be careful about the case of the empty list: char *remove_item(void) LISTITEM *old = list; char *string; if(old == NULL) fprintf(stderr, "cannot remove item from an empty list\n"); list = list->next; string = old->string; free(old); return string; Notice that we return the string (data value) to the caller, and deallocate the old node that was at the head of the list. We say that the caller now owns the storage required to hold the string - even though the caller did not initially allocate that storage. It will be up to the caller to deallocate that memory when no longer required. Failure to deallocate such memory can lead to memory leaks, that may eventually crash long running programs. CITS2002 Systems Programming, Lecture 19, p11, 8th October 2018.

12 prev 12 next CITS2002 CITS2002 schedule Problems with our list data structure As written, our list data structure works, but also has a few problems: Again, our list accessing functions use a single global variable. What if our program required 2, or more, lists? Continually searching for the end-of-list can become expensive. Could the lists be manipulated by functions that didn't actually "understand" the data they were manipulating? We'll address all of these by developing a similar first-in-first-out (FIFO) data structure, which we'll name a queue. CITS2002 Systems Programming, Lecture 19, p12, 8th October 2018.

13 prev 13 next CITS2002 CITS2002 schedule A general-purpose queue data structure Let's develop a first-in-first-out (FIFO) data structure that queues (almost) arbitrary data. We're hoping to address the main problems that were exhibited by the stack and list data structures: We should be able to manage the data without knowing what it is. We'd like operations, such as appending, to be independent of the number of items already stored. Such (highly desirable) operations are performed in a constant-time. typedef struct _e void *data; size_t datalen; struct _e *next; ELEMENT; typedef struct ELEMENT *head; ELEMENT *tail; QUEUE; Of note: We've introduced a new datatype, ELEMENT, to hold each individual item of data. Because we don't require our functions to "understand" the data they're queueing, each element will just hold a void pointer to the data it's holding, and remember its length. Our "traditional" datatype QUEUE now holds 2 pointers - one to the head of the list of items, one to the tail. CITS2002 Systems Programming, Lecture 19, p13, 8th October 2018.

14 prev 14 next CITS2002 CITS2002 schedule Creating a new queue We'd like our large programs to have more than a single queue - thus we don't want a single, global, variable, and we don't know until run-time how many queues we'll require. We thus need a function to allocate space for, and to initialize, a new queue: QUEUE *queue_new(void) QUEUE *q = malloc( sizeof(queue) ); if(q == NULL) perror( func ); q->head = NULL; q->tail = NULL; return q;... QUEUE *people_queue = queue_new(); QUEUE *truck_queue = queue_new(); QUEUE *queue_new(void) // same outcome, often seen QUEUE *q = calloc( 1, sizeof(queue) ); if(q == NULL) perror( func ); return q; If we remember that: the calloc function both allocates memory and sets all of its bytes to the zero-bit-pattern, and that (most) C99 implementations represent the NULL pointer as the zero-bit-pattern, then we appreciate the simplicity of allocating new items with calloc. CITS2002 Systems Programming, Lecture 19, p14, 8th October 2018.

15 prev 15 next CITS2002 CITS2002 schedule Deallocating space used by our queue It's considered a good practice to always write a function that deallocates all space used in our own user-defined dynamic data structures. In the case of our queue, we need to deallocate 3 things: 1. the memory required for the data in every element, 2. the memory required for every element, 3. the queue itself. void queue_free(queue *q) ELEMENT *this, *save; this = q->head; while( this!= NULL ) save = this; this = this->next; free(save->data); free(save); free(q); QUEUE *my_queue = queue_new();... // use my local queue... queue_free( my_queue ); CITS2002 Systems Programming, Lecture 19, p15, 8th October 2018.

16 prev 16 next CITS2002 CITS2002 schedule Adding (appending) new items to our queue Finally, we'll considered adding new items to our queue. Remember two of our objectives: To quickly add items - we don't wish appending to a very long queue to be slow. We achieve this by remembering where the tail of the queue is, and quickly adding to it without searching. To be able to queue data that we don't "understand". We achieve this by treating all data as "a block of bytes", allocating memory for it, copying it (as we're told its length), all without ever interpreting its contents. CITS2002 Systems Programming, Lecture 19, p16, 8th October 2018.

17 prev 17 next CITS2002 CITS2002 schedule Adding (appending) new items to our queue, continued void queue_add(queue *Q, void *data, size_t datalen) ELEMENT *newelement; // ALLOCATE MEMORY FOR A NEW ELEMENT newelement = calloc(1, sizeof(element)); if(newelement == NULL) perror( func ); // ALLOCATE MEMORY FOR THE DATA IN THE NEW ELEMENT newelement->data = malloc(datalen); if(newelement->data == NULL) perror( func ); // SAVE (COPY) THE UNKNOWN DATA INTO OUR NEW MEMORY memcpy(newelement->data, data, datalen); newelement->datalen = datalen; newelement->next = NULL; // APPEND THE NEW ELEMENT TO AN EMPTY LIST if(q->head == NULL) q->head = newelement; q->tail = newelement; // OR APPEND THE NEW ELEMENT TO THE TAIL OF THE LIST else q->tail->next = newelement; q->tail = newelement; Writing a function to remove items from our queue, is left as a simple exercise. CITS2002 Systems Programming, Lecture 19, p17, 8th October 2018.

18 prev 18 next CITS2002 CITS2002 schedule Storing and searching ordered data - a binary tree Each of the previous self-referential data-structures stored their values in their order of arrival, and accessed or removed them in the same order or the reverse. The actual time of insertion is immaterial, with the relative times 'embedded' in the order of the elements. More common is to store data in a structure that embeds the relative magnitude or priority of the data. Doing so requires insertions to keep the datastructure ordered, but this makes searching much quicker as well. Let's consider the type definition and insertion of data into a binary tree in C99: typedef struct _bt int value; struct _bt *left; struct _bt *right; BINTREE; BINTREE *tree_root = NULL; BINTREE *tree_insert(bintree *t, int value) if(t == NULL) BINTREE *new = calloc(1, sizeof(bintree)); if(new == NULL) perror( func ); new->value = value; // the calloc() call has set both left and right to NULL return new; int order = (t->value - value); if(order > 0) t->left = tree_insert(t->left, value); else if(order < 0) t->right = tree_insert(t->right, value); return t; Of note: we've defined a data-structure containing two pointers to other instances of the data-structure. the use of the struct _bt data type is temporary, and never used again. here, each element of the data-structure, each node of the tree, holds a unique instance of a data value - here, a single integer - though it's very common to hold multiple data values. we insert into the tree with: tree_root = tree_insert(tree_root, new_value); the (magnitude of the) integer data value embeds the order of the structure - elements with lesser integer values are stored 'below' and to the left of the current node, higher values to the right. unlike some (more complicated) variants of the binary-tree, we've made no effort to keep the tree balanced. If we insert already sorted elements into the tree, the tree will degenerate into a list, with every node having either a NULL left or a NULL right pointer. CITS2002 Systems Programming, Lecture 19, p18, 8th October 2018.

19 prev 19 CITS2002 CITS2002 schedule Storing and searching ordered data - a binary tree, continued Knowing that we've built the binary tree to maintain an order of its elements, we exploit this property to find elements: bool find_recursively(bintree *t, int wanted) if(t!= NULL) int order = (t->value - wanted); if(order == 0) return true; else if(order > 0) return find_recursively(t->left, wanted); else return find_recursively(t->right, wanted); return false; bool find_iteratively(bintree *t, int wanted) while(t!= NULL) int order = (t->value - wanted); if(order == 0) return true; else if(order > 0) t = t->left; else t = t->right; return false; Of note: we search for a value in the tree with: bool found = find_recursively(tree_root, wanted_value); we do not modify the tree when searching, we simply 'walk' over its elements, determining whether to go-left or go-right depending on the relative value of each element's data to the wanted value. some (more complicated) variants of the binary-tree re-balance the tree by moving recently found values (their nodes) closer to the root of the tree in the hope that they'll be required again, soon. if the required value if found, the searching functions return true; otherwise we keep walking the tree until we find the value or until we can no longer walk in the required direction (because either the left or the right pointer is NULL). CITS2002 Systems Programming, Lecture 19, p19, 8th October 2018.

Cpt S 122 Data Structures. Data Structures

Cpt S 122 Data Structures. Data Structures Cpt S 122 Data Structures Data Structures Nirmalya Roy School of Electrical Engineering and Computer Science Washington State University Topics Introduction Self Referential Structures Dynamic Memory Allocation

More information

Cpt S 122 Data Structures. Course Review Midterm Exam # 1

Cpt S 122 Data Structures. Course Review Midterm Exam # 1 Cpt S 122 Data Structures Course Review Midterm Exam # 1 Nirmalya Roy School of Electrical Engineering and Computer Science Washington State University Midterm Exam 1 When: Friday (09/28) 12:10-1pm Where:

More information

CP2 Revision. theme: dynamic datatypes & data structures

CP2 Revision. theme: dynamic datatypes & data structures CP2 Revision theme: dynamic datatypes & data structures structs can hold any combination of datatypes handled as single entity struct { }; ;

More information

C Data Structures Stacks. Stack. push Adds a new node to the top of the stack

C Data Structures Stacks. Stack. push Adds a new node to the top of the stack 1 12 C Data Structures 12.5 Stacks 2 Stack New nodes can be added and removed only at the top Similar to a pile of dishes Last-in, first-out (LIFO) Bottom of stack indicated by a link member to NULL Constrained

More information

Here's how you declare a function that returns a pointer to a character:

Here's how you declare a function that returns a pointer to a character: 23 of 40 3/28/2013 10:35 PM Violets are blue Roses are red C has been around, But it is new to you! ANALYSIS: Lines 32 and 33 in main() prompt the user for the desired sort order. The value entered is

More information

In Java we have the keyword null, which is the value of an uninitialized reference type

In Java we have the keyword null, which is the value of an uninitialized reference type + More on Pointers + Null pointers In Java we have the keyword null, which is the value of an uninitialized reference type In C we sometimes use NULL, but its just a macro for the integer 0 Pointers are

More information

COMP26120: Linked List in C (2018/19) Lucas Cordeiro

COMP26120: Linked List in C (2018/19) Lucas Cordeiro COMP26120: Linked List in C (2018/19) Lucas Cordeiro lucas.cordeiro@manchester.ac.uk Linked List Lucas Cordeiro (Formal Methods Group) lucas.cordeiro@manchester.ac.uk Office: 2.28 Office hours: 10-11 Tuesday,

More information

Data Structure Series

Data Structure Series Data Structure Series This series is actually something I started back when I was part of the Sweet.Oblivion staff, but then some things happened and I was no longer able to complete it. So now, after

More information

Programs in memory. The layout of memory is roughly:

Programs in memory. The layout of memory is roughly: Memory 1 Programs in memory 2 The layout of memory is roughly: Virtual memory means that memory is allocated in pages or segments, accessed as if adjacent - the platform looks after this, so your program

More information

CS11001/CS11002 Programming and Data Structures (PDS) (Theory: 3-1-0) Allocating Space

CS11001/CS11002 Programming and Data Structures (PDS) (Theory: 3-1-0) Allocating Space CS11001/CS11002 Programming and Data Structures (PDS) (Theory: 3-1-0) Allocating Space Dynamic Memory Allocation All variables, arrays, structures and unions that we worked with so far are statically allocated,

More information

CS 11 C track: lecture 6

CS 11 C track: lecture 6 CS 11 C track: lecture 6 Last week: pointer arithmetic This week: The gdb program struct typedef linked lists gdb for debugging (1) gdb: the Gnu DeBugger http://courses.cms.caltech.edu/cs11/material /c/mike/misc/gdb.html

More information

Programming in C. Lecture Tiina Niklander. Faculty of Science

Programming in C. Lecture Tiina Niklander. Faculty of Science Programming in C Lecture 3 17.9.2018 Tiina Niklander Faculty of Science Department of Computer Science 17.9.2018 1 Week 2 covers Pointer basics operators and address arithmetics as function argument Precedence

More information

INITIALISING POINTER VARIABLES; DYNAMIC VARIABLES; OPERATIONS ON POINTERS

INITIALISING POINTER VARIABLES; DYNAMIC VARIABLES; OPERATIONS ON POINTERS INITIALISING POINTER VARIABLES; DYNAMIC VARIABLES; OPERATIONS ON POINTERS Pages 792 to 800 Anna Rakitianskaia, University of Pretoria INITIALISING POINTER VARIABLES Pointer variables are declared by putting

More information

The combination of pointers, structs, and dynamic memory allocation allow for creation of data structures

The combination of pointers, structs, and dynamic memory allocation allow for creation of data structures Data Structures in C C Programming and Software Tools N.C. State Department of Computer Science Data Structures in C The combination of pointers, structs, and dynamic memory allocation allow for creation

More information

CS 11 C track: lecture 5

CS 11 C track: lecture 5 CS 11 C track: lecture 5 Last week: pointers This week: Pointer arithmetic Arrays and pointers Dynamic memory allocation The stack and the heap Pointers (from last week) Address: location where data stored

More information

Lecture Notes on Memory Management

Lecture Notes on Memory Management Lecture Notes on Memory Management 15-122: Principles of Imperative Computation Frank Pfenning Lecture 22 November 11, 2010 1 Introduction Unlike C0 and other modern languages like Java, C#, or ML, C requires

More information

CA341 - Comparative Programming Languages

CA341 - Comparative Programming Languages CA341 - Comparative Programming Languages David Sinclair Dynamic Data Structures Generally we do not know how much data a program will have to process. There are 2 ways to handle this: Create a fixed data

More information

Understanding Pointers

Understanding Pointers Division of Mathematics and Computer Science Maryville College Pointers and Addresses Memory is organized into a big array. Every data item occupies one or more cells. A pointer stores an address. A pointer

More information

Kurt Schmidt. October 30, 2018

Kurt Schmidt. October 30, 2018 to Structs Dept. of Computer Science, Drexel University October 30, 2018 Array Objectives to Structs Intended audience: Student who has working knowledge of Python To gain some experience with a statically-typed

More information

Algorithms, Data Structures, and Problem Solving

Algorithms, Data Structures, and Problem Solving Algorithms, Data Structures, and Problem Solving Masoumeh Taromirad Hamlstad University DT4002, Fall 2016 Container Concepts containers store data container operations: insertion retrieval removal iteration

More information

Lecture 10 Notes Linked Lists

Lecture 10 Notes Linked Lists Lecture 10 Notes Linked Lists 15-122: Principles of Imperative Computation (Summer 1 2015) Frank Pfenning, Rob Simmons, André Platzer 1 Introduction In this lecture we discuss the use of linked lists to

More information

Solution for Data Structure

Solution for Data Structure Solution for Data Structure May 2016 INDEX Q1 a 2-3 b 4 c. 4-6 d 7 Q2- a 8-12 b 12-14 Q3 a 15-18 b 18-22 Q4- a 22-35 B..N.A Q5 a 36-38 b N.A Q6- a 39-42 b 43 1 www.brainheaters.in Q1) Ans: (a) Define ADT

More information

BBM 201 DATA STRUCTURES

BBM 201 DATA STRUCTURES BBM 201 DATA STRUCTURES Lecture 8: Dynamically Allocated Linked Lists 2017-2018 Fall int x; x = 8; int A[4]; An array is stored as one contiguous block of memory. How can we add a fifth element to the

More information

Lecture 10 Notes Linked Lists

Lecture 10 Notes Linked Lists Lecture 10 Notes Linked Lists 15-122: Principles of Imperative Computation (Spring 2016) Frank Pfenning, Rob Simmons, André Platzer 1 Introduction In this lecture we discuss the use of linked lists to

More information

Pointers. A pointer is simply a reference to a variable/object. Compilers automatically generate code to store/retrieve variables from memory

Pointers. A pointer is simply a reference to a variable/object. Compilers automatically generate code to store/retrieve variables from memory Pointers A pointer is simply a reference to a variable/object Compilers automatically generate code to store/retrieve variables from memory It is automatically generating internal pointers We don t have

More information

Programming. Lists, Stacks, Queues

Programming. Lists, Stacks, Queues Programming Lists, Stacks, Queues Summary Linked lists Create and insert elements Iterate over all elements of the list Remove elements Doubly Linked Lists Circular Linked Lists Stacks Operations and implementation

More information

CS61, Fall 2012 Section 2 Notes

CS61, Fall 2012 Section 2 Notes CS61, Fall 2012 Section 2 Notes (Week of 9/24-9/28) 0. Get source code for section [optional] 1: Variable Duration 2: Memory Errors Common Errors with memory and pointers Valgrind + GDB Common Memory Errors

More information

CS6202 - PROGRAMMING & DATA STRUCTURES I Unit IV Part - A 1. Define Stack. A stack is an ordered list in which all insertions and deletions are made at one end, called the top. It is an abstract data type

More information

Lecture 8 Dynamic Memory Allocation

Lecture 8 Dynamic Memory Allocation Lecture 8 Dynamic Memory Allocation CS240 1 Memory Computer programs manipulate an abstraction of the computer s memory subsystem Memory: on the hardware side 3 @ http://computer.howstuffworks.com/computer-memory.htm/printable

More information

CSCI 171 Chapter Outlines

CSCI 171 Chapter Outlines Contents CSCI 171 Chapter 1 Overview... 2 CSCI 171 Chapter 2 Programming Components... 3 CSCI 171 Chapter 3 (Sections 1 4) Selection Structures... 5 CSCI 171 Chapter 3 (Sections 5 & 6) Iteration Structures

More information

CSC 1600 Memory Layout for Unix Processes"

CSC 1600 Memory Layout for Unix Processes CSC 16 Memory Layout for Unix Processes" 1 Lecture Goals" Behind the scenes of running a program" Code, executable, and process" Memory layout for UNIX processes, and relationship to C" : code and constant

More information

ch = argv[i][++j]; /* why does ++j but j++ does not? */

ch = argv[i][++j]; /* why does ++j but j++ does not? */ CMPS 12M Introduction to Data Structures Lab Lab Assignment 4 The purpose of this lab assignment is to get more practice programming in C, including the character functions in the library ctype.h, and

More information

However, in C we can group related variables together into something called a struct.

However, in C we can group related variables together into something called a struct. CIT 593: Intro to Computer Systems Lecture #21 (11/27/12) Structs Unlike Java, C++, and to some extent Python, C is not traditionally considered an objectoriented language. That is, there is no concept

More information

Dynamic Memory Management. Bin Li Assistant Professor Dept. of Electrical, Computer and Biomedical Engineering University of Rhode Island

Dynamic Memory Management. Bin Li Assistant Professor Dept. of Electrical, Computer and Biomedical Engineering University of Rhode Island Dynamic Memory Management Bin Li Assistant Professor Dept. of Electrical, Computer and Biomedical Engineering University of Rhode Island 1 Dynamic Memory Allocation Dynamic memory allocation is used to

More information

Lecture Notes on Queues

Lecture Notes on Queues Lecture Notes on Queues 15-122: Principles of Imperative Computation Frank Pfenning and Jamie Morgenstern Lecture 9 February 14, 2012 1 Introduction In this lecture we introduce queues as a data structure

More information

Linked Lists and Abstract Data Structures A brief comparison

Linked Lists and Abstract Data Structures A brief comparison Linked Lists and Abstract Data A brief comparison 24 March 2011 Outline 1 2 3 4 Data Data structures are a key idea in programming It s just as important how you store the data as it is what you do to

More information

Arrays and Memory Management

Arrays and Memory Management Arrays and Memory Management 1 Pointing to Different Size Objects Modern machines are byte-addressable Hardware s memory composed of 8-bit storage cells, each has a unique address A C pointer is just abstracted

More information

Dynamic memory allocation

Dynamic memory allocation Dynamic memory allocation outline Memory allocation functions Array allocation Matrix allocation Examples Memory allocation functions (#include ) malloc() Allocates a specified number of bytes

More information

Memory. What is memory? How is memory organized? Storage for variables, data, code etc. Text (Code) Data (Constants) BSS (Global and static variables)

Memory. What is memory? How is memory organized? Storage for variables, data, code etc. Text (Code) Data (Constants) BSS (Global and static variables) Memory Allocation Memory What is memory? Storage for variables, data, code etc. How is memory organized? Text (Code) Data (Constants) BSS (Global and static variables) Text Data BSS Heap Stack (Local variables)

More information

Lecture Notes on Memory Layout

Lecture Notes on Memory Layout Lecture Notes on Memory Layout 15-122: Principles of Imperative Computation Frank Pfenning André Platzer Lecture 11 1 Introduction In order to understand how programs work, we can consider the functions,

More information

Summer Final Exam Review Session August 5, 2009

Summer Final Exam Review Session August 5, 2009 15-111 Summer 2 2009 Final Exam Review Session August 5, 2009 Exam Notes The exam is from 10:30 to 1:30 PM in Wean Hall 5419A. The exam will be primarily conceptual. The major emphasis is on understanding

More information

CS 241 Data Organization Binary Trees

CS 241 Data Organization Binary Trees CS 241 Data Organization Binary Trees Brooke Chenoweth University of New Mexico Fall 2017 Binary Tree: Kernighan and Ritchie 6.5 Read a file and count the occurrences of each word. now is the time for

More information

Introduction to Data Structures. Systems Programming

Introduction to Data Structures. Systems Programming Introduction to Data Structures Systems Programming Intro to Data Structures Self-referential Structures Dynamic Memory Allocation A Simple malloc Example Linear Lists Linked Lists Insertion Example Linked

More information

Linked Lists. What is a Linked List?

Linked Lists. What is a Linked List? Linked Lists Along with arrays, linked lists form the basis for pretty much every other data stucture out there. This makes learning and understand linked lists very important. They are also usually the

More information

Outline. Computer programming. Usage of time and date functions. Date and Time: time.h. Date and Time: time.h. Time functions:

Outline. Computer programming. Usage of time and date functions. Date and Time: time.h. Date and Time: time.h. Time functions: Outline Computer programming "An expert is a man who has made all the mistakes which can be made, in a narrow field." Niels Bohr Working with time I/O redirection Variable length argument lists Command

More information

19-Nov CSCI 2132 Software Development Lecture 29: Linked Lists. Faculty of Computer Science, Dalhousie University Heap (Free Store)

19-Nov CSCI 2132 Software Development Lecture 29: Linked Lists. Faculty of Computer Science, Dalhousie University Heap (Free Store) Lecture 29 p.1 Faculty of Computer Science, Dalhousie University CSCI 2132 Software Development Lecture 29: Linked Lists 19-Nov-2018 Location: Chemistry 125 Time: 12:35 13:25 Instructor: Vlado Keselj Previous

More information

CS107 Handout 08 Spring 2007 April 9, 2007 The Ins and Outs of C Arrays

CS107 Handout 08 Spring 2007 April 9, 2007 The Ins and Outs of C Arrays CS107 Handout 08 Spring 2007 April 9, 2007 The Ins and Outs of C Arrays C Arrays This handout was written by Nick Parlante and Julie Zelenski. As you recall, a C array is formed by laying out all the elements

More information

Computer programming. "An expert is a man who has made all the mistakes which can be made, in a narrow field." Niels Bohr

Computer programming. An expert is a man who has made all the mistakes which can be made, in a narrow field. Niels Bohr Computer programming "An expert is a man who has made all the mistakes which can be made, in a narrow field." Niels Bohr 1 Outline Working with time I/O redirection Variable length argument lists Command

More information

11 'e' 'x' 'e' 'm' 'p' 'l' 'i' 'f' 'i' 'e' 'd' bool equal(const unsigned char pstr[], const char *cstr) {

11 'e' 'x' 'e' 'm' 'p' 'l' 'i' 'f' 'i' 'e' 'd' bool equal(const unsigned char pstr[], const char *cstr) { This document contains the questions and solutions to the CS107 midterm given in Spring 2016 by instructors Julie Zelenski and Michael Chang. This was an 80-minute exam. Midterm questions Problem 1: C-strings

More information

DAY 3. CS3600, Northeastern University. Alan Mislove

DAY 3. CS3600, Northeastern University. Alan Mislove C BOOTCAMP DAY 3 CS3600, Northeastern University Slides adapted from Anandha Gopalan s CS132 course at Univ. of Pittsburgh and Pascal Meunier s course at Purdue Memory management 2 Memory management Two

More information

Midterm Review. CS 211 Fall 2018

Midterm Review. CS 211 Fall 2018 Midterm Review CS 211 Fall 2018 BSB 250 Official Time: 10:00 am to 10:50 am If we can start a few minutes early, we will So try to arrive closer to 9:50am We will need to finish right at 10:50 since there

More information

CS11001/CS11002 Programming and Data Structures (PDS) (Theory: 3-1-0)

CS11001/CS11002 Programming and Data Structures (PDS) (Theory: 3-1-0) CS11001/CS11002 Programming and Data Structures (PDS) (Theory: 3-1-0) Dynamic Memory Allocation All variables, arrays, structures and unions that we worked with so far are statically allocated, meaning

More information

An Introduction to Trees

An Introduction to Trees An Introduction to Trees Alice E. Fischer Spring 2017 Alice E. Fischer An Introduction to Trees... 1/34 Spring 2017 1 / 34 Outline 1 Trees the Abstraction Definitions 2 Expression Trees 3 Binary Search

More information

Short Notes of CS201

Short Notes of CS201 #includes: Short Notes of CS201 The #include directive instructs the preprocessor to read and include a file into a source code file. The file name is typically enclosed with < and > if the file is a system

More information

Week 5, continued. This is CS50. Harvard University. Fall Cheng Gong

Week 5, continued. This is CS50. Harvard University. Fall Cheng Gong This is CS50. Harvard University. Fall 2014. Cheng Gong Table of Contents News... 1 Buffer Overflow... 1 Malloc... 6 Linked Lists... 7 Searching... 13 Inserting... 16 Removing... 19 News Good news everyone!

More information

Linked List. April 2, 2007 Programming and Data Structure 1

Linked List. April 2, 2007 Programming and Data Structure 1 Linked List April 2, 2007 Programming and Data Structure 1 Introduction head A linked list is a data structure which can change during execution. Successive elements are connected by pointers. Last element

More information

Lecture Notes on Memory Management

Lecture Notes on Memory Management Lecture Notes on Memory Management 15-122: Principles of Imperative Computation Frank Pfenning Lecture 21 April 5, 2011 1 Introduction Unlike C0 and other modern languages like Java, C#, or ML, C requires

More information

CS 237 Meeting 19 10/24/12

CS 237 Meeting 19 10/24/12 CS 237 Meeting 19 10/24/12 Announcements 1. Midterm: New date: Oct 29th. In class open book/notes. 2. Try to complete the linear feedback shift register lab in one sitting (and please put all the equipment

More information

CS201 - Introduction to Programming Glossary By

CS201 - Introduction to Programming Glossary By CS201 - Introduction to Programming Glossary By #include : The #include directive instructs the preprocessor to read and include a file into a source code file. The file name is typically enclosed with

More information

Lecture Notes on Queues

Lecture Notes on Queues Lecture Notes on Queues 15-122: Principles of Imperative Computation Frank Pfenning Lecture 9 September 25, 2012 1 Introduction In this lecture we introduce queues as a data structure and linked lists

More information

Declaring Pointers. Declaration of pointers <type> *variable <type> *variable = initial-value Examples:

Declaring Pointers. Declaration of pointers <type> *variable <type> *variable = initial-value Examples: 1 Programming in C Pointer Variable A variable that stores a memory address Allows C programs to simulate call-by-reference Allows a programmer to create and manipulate dynamic data structures Must be

More information

Dynamic Memory Allocation and Command-line Arguments

Dynamic Memory Allocation and Command-line Arguments Dynamic Memory Allocation and Command-line Arguments CSC209: Software Tools and Systems Programming Furkan Alaca & Paul Vrbik University of Toronto Mississauga https://mcs.utm.utoronto.ca/~209/ Week 3

More information

l Determine if a number is odd or even l Determine if a number/character is in a range - 1 to 10 (inclusive) - between a and z (inclusive)

l Determine if a number is odd or even l Determine if a number/character is in a range - 1 to 10 (inclusive) - between a and z (inclusive) Final Exam Exercises Chapters 1-7 + 11 Write C++ code to: l Determine if a number is odd or even CS 2308 Fall 2016 Jill Seaman l Determine if a number/character is in a range - 1 to 10 (inclusive) - between

More information

When you add a number to a pointer, that number is added, but first it is multiplied by the sizeof the type the pointer points to.

When you add a number to a pointer, that number is added, but first it is multiplied by the sizeof the type the pointer points to. Refresher When you add a number to a pointer, that number is added, but first it is multiplied by the sizeof the type the pointer points to. i.e. char *ptr1 = malloc(1); ptr1 + 1; // adds 1 to pointer

More information

211: Computer Architecture Summer 2016

211: Computer Architecture Summer 2016 211: Computer Architecture Summer 2016 Liu Liu Topic: C Programming Data Representation I/O: - (example) cprintf.c Memory: - memory address - stack / heap / constant space - basic data layout Pointer:

More information

CS 103 Unit 11. Linked Lists. Mark Redekopp

CS 103 Unit 11. Linked Lists. Mark Redekopp 1 CS 103 Unit 11 Linked Lists Mark Redekopp 2 NULL Pointer Just like there was a null character in ASCII = '\0' whose ue was 0 There is a NULL pointer whose ue is 0 NULL is "keyword" you can use in C/C++

More information

Lecture 7: Data Structures. EE3490E: Programming S1 2017/2018 Dr. Đào Trung Kiên Hanoi Univ. of Science and Technology

Lecture 7: Data Structures. EE3490E: Programming S1 2017/2018 Dr. Đào Trung Kiên Hanoi Univ. of Science and Technology Lecture 7: Data Structures 1 Introduction: dynamic array Conventional array in C has fix number of elements Dynamic array is array with variable number of elements: actually a pointer and a variable indicating

More information

printf( Please enter another number: ); scanf( %d, &num2);

printf( Please enter another number: ); scanf( %d, &num2); CIT 593 Intro to Computer Systems Lecture #13 (11/1/12) Now that we've looked at how an assembly language program runs on a computer, we're ready to move up a level and start working with more powerful

More information

Linked List in Data Structure. By Prof. B J Gorad, BECSE, M.Tech CST, PHD(CSE)* Assistant Professor, CSE, SITCOE, Ichalkaranji,Kolhapur, Maharashtra

Linked List in Data Structure. By Prof. B J Gorad, BECSE, M.Tech CST, PHD(CSE)* Assistant Professor, CSE, SITCOE, Ichalkaranji,Kolhapur, Maharashtra Linked List in Data Structure By Prof. B J Gorad, BECSE, M.Tech CST, PHD(CSE)* Assistant Professor, CSE, SITCOE, Ichalkaranji,Kolhapur, Maharashtra Linked List Like arrays, Linked List is a linear data

More information

Linked Lists in C and C++

Linked Lists in C and C++ Linked Lists in C and C++ Professor Hugh C. Lauer CS-2303, System Programming Concepts (Slides include materials from The C Programming Language, 2 nd edition, by Kernighan and Ritchie, Absolute C++, by

More information

CS107, Lecture 9 C Generics Function Pointers

CS107, Lecture 9 C Generics Function Pointers CS107, Lecture 9 C Generics Function Pointers Reading: K&R 5.11 This document is copyright (C) Stanford Computer Science and Nick Troccoli, licensed under Creative Commons Attribution 2.5 License. All

More information

Memory Management. a C view. Dr Alun Moon KF5010. Computer Science. Dr Alun Moon (Computer Science) Memory Management KF / 24

Memory Management. a C view. Dr Alun Moon KF5010. Computer Science. Dr Alun Moon (Computer Science) Memory Management KF / 24 Memory Management a C view Dr Alun Moon Computer Science KF5010 Dr Alun Moon (Computer Science) Memory Management KF5010 1 / 24 The Von Neumann model Memory Architecture One continuous address space Program

More information

Ashish Gupta, Data JUET, Guna

Ashish Gupta, Data JUET, Guna Categories of data structures Data structures are categories in two classes 1. Linear data structure: - organized into sequential fashion - elements are attached one after another - easy to implement because

More information

Linked Lists, Stacks, and Queues

Linked Lists, Stacks, and Queues Department of Computer Science and Engineering Chinese University of Hong Kong In a nutshell, a data structure describes how data are stored in memory, in order to facilitate certain operations. In all

More information

CS32 - Week 2. Umut Oztok. July 1, Umut Oztok CS32 - Week 2

CS32 - Week 2. Umut Oztok. July 1, Umut Oztok CS32 - Week 2 CS32 - Week 2 Umut Oztok July 1, 2016 Arrays A basic data structure (commonly used). Organize data in a sequential way. Arrays A basic data structure (commonly used). Organize data in a sequential way.

More information

A. Year / Module Semester Subject Topic 2016 / V 2 PCD Pointers, Preprocessors, DS

A. Year / Module Semester Subject Topic 2016 / V 2 PCD Pointers, Preprocessors, DS Syllabus: Pointers and Preprocessors: Pointers and address, pointers and functions (call by reference) arguments, pointers and arrays, address arithmetic, character pointer and functions, pointers to pointer,initialization

More information

This document contains the questions and solutions to the CS107 midterm given in Winter 2018 by instructor Chris Gregg. This was a 120-minute exam.

This document contains the questions and solutions to the CS107 midterm given in Winter 2018 by instructor Chris Gregg. This was a 120-minute exam. This document contains the questions and solutions to the CS107 midterm given in Winter 2018 by instructor Chris Gregg. This was a 120-minute exam. Midterm questions Problem 1: Bits, bytes, and numbers

More information

Lecture 14. No in-class files today. Homework 7 (due on Wednesday) and Project 3 (due in 10 days) posted. Questions?

Lecture 14. No in-class files today. Homework 7 (due on Wednesday) and Project 3 (due in 10 days) posted. Questions? Lecture 14 No in-class files today. Homework 7 (due on Wednesday) and Project 3 (due in 10 days) posted. Questions? Friday, February 11 CS 215 Fundamentals of Programming II - Lecture 14 1 Outline Static

More information

CSC209H Lecture 3. Dan Zingaro. January 21, 2015

CSC209H Lecture 3. Dan Zingaro. January 21, 2015 CSC209H Lecture 3 Dan Zingaro January 21, 2015 Streams (King 22.1) Stream: source of input or destination for output We access a stream through a file pointer (FILE *) Three streams are available without

More information

So on the survey, someone mentioned they wanted to work on heaps, and someone else mentioned they wanted to work on balanced binary search trees.

So on the survey, someone mentioned they wanted to work on heaps, and someone else mentioned they wanted to work on balanced binary search trees. So on the survey, someone mentioned they wanted to work on heaps, and someone else mentioned they wanted to work on balanced binary search trees. According to the 161 schedule, heaps were last week, hashing

More information

15. Stacks and Queues

15. Stacks and Queues COMP1917 15s2 15. Stacks and Queues 1 COMP1917: Computing 1 15. Stacks and Queues Reading: Moffat, Section 10.1-10.2 Overview Stacks Queues Adding to the Tail of a List Efficiency Issues Queue Structure

More information

ESc101: (Linear, Circular, Doubly) Linked Lists, Stacks, Queues, Trees. Introduction to Linked Lists

ESc101: (Linear, Circular, Doubly) Linked Lists, Stacks, Queues, Trees. Introduction to Linked Lists ESc101: (Linear, Circular, Doubly) Linked Lists, Stacks, Queues, Trees Instructor: Krithika Venkataramani Semester 2, 2011-2012 1 Introduction to Linked Lists Each bead connected to the next through a

More information

CS 2113 Software Engineering

CS 2113 Software Engineering CS 2113 Software Engineering Do this now!!! From C to Java git clone https://github.com/cs2113f18/c-to-java.git cd c-to-java./install_java Professor Tim Wood - The George Washington University We finished

More information

CSCI-243 Exam 1 Review February 22, 2015 Presented by the RIT Computer Science Community

CSCI-243 Exam 1 Review February 22, 2015 Presented by the RIT Computer Science Community CSCI-243 Exam 1 Review February 22, 2015 Presented by the RIT Computer Science Community http://csc.cs.rit.edu History and Evolution of Programming Languages 1. Explain the relationship between machine

More information

ECE264 Fall 2013 Exam 3, November 20, 2013

ECE264 Fall 2013 Exam 3, November 20, 2013 ECE264 Fall 2013 Exam 3, November 20, 2013 In signing this statement, I hereby certify that the work on this exam is my own and that I have not copied the work of any other student while completing it.

More information

Dynamic Data Structures (II)

Dynamic Data Structures (II) Lecture 23 Dynamic Data Structures (II) CptS 121 Summer 2016 Armen Abnousi Data Structure Data structures are different ways of organizing data in computer We design new data structures to make the programs

More information

Chapter 1 Getting Started

Chapter 1 Getting Started Chapter 1 Getting Started The C# class Just like all object oriented programming languages, C# supports the concept of a class. A class is a little like a data structure in that it aggregates different

More information

Procedural programming with C

Procedural programming with C Procedural programming with C Dr. C. Constantinides Department of Computer Science and Software Engineering Concordia University Montreal, Canada August 11, 2016 1 / 77 Functions Similarly to its mathematical

More information

FORTH SEMESTER DIPLOMA EXAMINATION IN ENGINEERING/ TECHNOLIGY- OCTOBER, 2012 DATA STRUCTURE

FORTH SEMESTER DIPLOMA EXAMINATION IN ENGINEERING/ TECHNOLIGY- OCTOBER, 2012 DATA STRUCTURE TED (10)-3071 Reg. No.. (REVISION-2010) Signature. FORTH SEMESTER DIPLOMA EXAMINATION IN ENGINEERING/ TECHNOLIGY- OCTOBER, 2012 DATA STRUCTURE (Common to CT and IF) [Time: 3 hours (Maximum marks: 100)

More information

APS105. Malloc and 2D Arrays. Textbook Chapters 6.4, Datatype Size

APS105. Malloc and 2D Arrays. Textbook Chapters 6.4, Datatype Size APS105 Malloc and 2D Arrays Textbook Chapters 6.4, 10.2 Datatype Size Datatypes have varying size: char: 1B int: 4B double: 8B int sizeof(): a builtin function that returns size of a type int x =

More information

CS 610: Intermediate Programming: C/C++ Making Programs General An Introduction to Linked Lists

CS 610: Intermediate Programming: C/C++ Making Programs General An Introduction to Linked Lists ... 1/17 CS 610: Intermediate Programming: C/C++ Making Programs General An Introduction to Linked Lists Alice E. Fischer Spring 2016 ... 2/17 Outline Generic Functions Command Line Arguments Review for

More information

Contents. A Review of C language. Visual C Visual C++ 6.0

Contents. A Review of C language. Visual C Visual C++ 6.0 A Review of C language C++ Object Oriented Programming Pei-yih Ting NTOU CS Modified from www.cse.cuhk.edu.hk/~csc2520/tuto/csc2520_tuto01.ppt 1 2 3 4 5 6 7 8 9 10 Double click 11 12 Compile a single source

More information

https://www.eskimo.com/~scs/cclass/notes/sx8.html

https://www.eskimo.com/~scs/cclass/notes/sx8.html 1 de 6 20-10-2015 10:41 Chapter 8: Strings Strings in C are represented by arrays of characters. The end of the string is marked with a special character, the null character, which is simply the character

More information

! Determine if a number is odd or even. ! Determine if a number/character is in a range. - 1 to 10 (inclusive) - between a and z (inclusive)

! Determine if a number is odd or even. ! Determine if a number/character is in a range. - 1 to 10 (inclusive) - between a and z (inclusive) Final Exam Exercises Chapters 1-7 + 11 Write C++ code to:! Determine if a number is odd or even CS 2308 Fall 2018 Jill Seaman! Determine if a number/character is in a range - 1 to 10 (inclusive) - between

More information

ECE 264 Exam 2. 6:30-7:30PM, March 9, You must sign here. Otherwise you will receive a 1-point penalty.

ECE 264 Exam 2. 6:30-7:30PM, March 9, You must sign here. Otherwise you will receive a 1-point penalty. ECE 264 Exam 2 6:30-7:30PM, March 9, 2011 I certify that I will not receive nor provide aid to any other student for this exam. Signature: You must sign here. Otherwise you will receive a 1-point penalty.

More information

C PROGRAMMING Lecture 5. 1st semester

C PROGRAMMING Lecture 5. 1st semester C PROGRAMMING Lecture 5 1st semester 2017-2018 Program Address Space The Stack The stack is the place where all local variables are stored a local variable is declared in some scope Example int x; //creates

More information

Intermediate Programming, Spring 2017*

Intermediate Programming, Spring 2017* 600.120 Intermediate Programming, Spring 2017* Misha Kazhdan *Much of the code in these examples is not commented because it would otherwise not fit on the slides. This is bad coding practice in general

More information

G Programming Languages - Fall 2012

G Programming Languages - Fall 2012 G22.2110-003 Programming Languages - Fall 2012 Lecture 4 Thomas Wies New York University Review Last week Control Structures Selection Loops Adding Invariants Outline Subprograms Calling Sequences Parameter

More information

CS 237 Meeting 18 10/22/12

CS 237 Meeting 18 10/22/12 CS 237 Meeting 18 10/22/12 Announcements 1. Midterm: New date: Oct 29th. In class open book/notes. 2. Duane Bailey has volunteered to do a chips and breadboards lab this week. Will any of you volunteer

More information

Lists (Section 5) Lists, linked lists Implementation of lists in C Other list structures List implementation of stacks, queues, priority queues

Lists (Section 5) Lists, linked lists Implementation of lists in C Other list structures List implementation of stacks, queues, priority queues (Section 5) Lists, linked lists Implementation of lists in C Other list structures List implementation of stacks, queues, priority queues By: Pramod Parajuli, Department of Computer Science, St. Xavier

More information