Save this PDF as:

Size: px
Start display at page:

## Transcription

1 C Programming, Exercises for the second week Notice: Remember that you can find information about a standard C library function by writing man 3 function_name in the terminal, or by going to the address: In this week exercises we learn to handle arrays and pointers. As a prerequisite for a successful programming you should know the various list data structures and their implementation principles. 1. A program has the following definitions and statements: int i, j=25; int *pi, *pj=&j; *pj=j+5; i= *pj+5; pi=pj; *pi=i+j; Test experimentally and explain the results: a) After the definitions, what values are represented by i, j, &i, &j? b) After the definitions, what values are represented by pi, pj, *pi, *pj? c) After the first statement, what values are represented by pj and *pj; d) After the second statement, what value is represented by i? e) After the third statement, what values are represented by pi and *pi? f) After the fourth statement, what values are represented by pi and *pi? 2. Assume that the following expressions are true: sizeof(short) == 2 sizeof(int) == 4 sizeof(float) == 4 sizeof(double) == 8 Also, assume that we have declared the array int arr[5] = { 0, 0, 0, 0, 0 }; Explain with a picture (hand-drawn is fine) where the following statements store values (both the location and the amount of bytes written). Assume that all the assignments succeed. 1

2 a) arr[3] = 42; b) arr[9] = 7; c) arr[-4] = 1; d) ((short*)arr)[7] = 128; e) ((double*)arr)[2] = 3.14; f) ((char*)&arr[1])[6] = A ; g) ((float*)(&((short*)&arr[3])[-3]))[0] = 7.5; (This is challenging!) (Hint: Remember that array indexing [] binds more tightly than the address-of operator and type conversions. Start analysing the more complex expressions from the inside.) If all the previous assignments succeed, which of the assignments have affected the value of: i) arr[0] ii) arr[2] iii) arr[4] 3. Write a function void print_doubles(double* array, int len); that prints the double values stored in the given array. The parameter len contains the number of double values in the array. Example call: double nums[5] = { , , , , }; print_doubles(nums, 5); Result of the example call: , , , , Write a function void shuffle_ints(int* array, int len); that shuffles the contents of the given array of integers. The parameter len contains the number of int values in the array. Write the shuffling code so that, given a random function with uniform distribution, every possible ordering of the contents is as likely. (Use the rand function provided by the standard C library.) Example call: int nums[] = { 0, 1, 2, 3, 4, 5, 6 }; shuffle_ints(nums, 7); 2

3 Example result: 1, 0, 6, 4, 3, 2, 5 5. In the exercise 1 we implemented operations for fractions. Represent now a fraction with the help of a structure: typedef struct { int numerator; int denumerator; } fraction; Implement the addition operation so that the function returns the sum in a structure: fraction addfractions(fraction r, fraction s); 6. Consider a doubly linked list (see the figures in the appendix) which contains integer values. Write the type definitions for this kind of a list (the name of the type could be dlist). 7. Write a function dlist* insertelementd(dlist *L, dlist *p, int value); which adds an integer value into the list L to the right side of position p. Take into account in this and other exercises that initially the list may be empty. The function returns a pointer to the start of the list. 8. Write a function int printelementsd(dlist *L); which prints the integers in the list. 9. Write a function dlist* deleteelementd(dlist *L, dlist *p); which deletes an element pointed by p from a doubly linked list. The function returns a pointer to the start of the list. 10. Write a function int orderlistd(dlist *L); which orders the values in the doubly linked list L from the smallest to the largest. The function returns 0, if everything succeeds. 3

4 11. Write a function dlist* mergelistsd(dlist *L1, dlist *L2); which merges ordered doubly linked lists Li and L2 into a third list which is ordered, too. 12. Consider a singly linked list which contains integer values. The lists have a header node. The header node contains at least the number of nodes and a pointer to the first data node. Write the type definitions and the function slist* createslist(void); which creates an empty list. 13. Write a function int insertelements(slist *L, slist *p, int value); which adds an integer value into the list L to the right side of position p. Check the next task and notice how the position pointer should be defined. The function returns 0, if everything succeeds. Test your function by printing the elements in the list just created with the help of insertelements. 14. Write a function int deleteelements(slist *L, slist *p); which deletes an element pointed by p from a singly linked list. The operation should work in a constant time. Thus you should think where the pointer p should point (see the appendix). The function returns 0, if the operation succeeds. 15. Write a function slist* mergelists(slist *L1, slist *L2); which merges ordered singly linked lists Li and L2 into a third singly linked list which is ordered, too. 4

5 APPENDIX: List Diagrams p L Figure 1: Doubly linked list p L Figure 2: After deleting the item 4 pointed by p 5

6 p s Figure 3: Singly linked list and position s pointed by p p Figure 4: Singly linked list after deleting the node s 6

### Standard Version of Starting Out with C++, 4th Edition. Linked Lists. Copyright 2003 Scott/Jones Publishing

To extend understanding of pointers by using them to create dynamic data structures Understand when to use a Linked List Be able to create a Linked List in C understand internals be able to program them!

### 1) The postfix expression for the infix expression A+B*(C+D)/F+D*E is ABCD+*F/DE*++

Answer the following 1) The postfix expression for the infix expression A+B*(C+D)/F+D*E is ABCD+*F/DE*++ 2) Which data structure is needed to convert infix notations to postfix notations? Stack 3) The

### Lecture 6b Linked List Variations. Similar but not the same

Lecture 6b Linked List Variations Similar but not the same Linked List Variations: Overview The linked list implementation used in List ADT is known as Singly (Single) Linked List Each node has one pointer

### BSc (Hons) Business Information Systems, BSc (Hons) Computer Science with Network Security. & BSc. (Hons.) Software Engineering

BSc (Hons) Business Information Systems, BSc (Hons) Computer Science with Network Security & BSc. (Hons.) Software Engineering Cohort: BIS/05/FT BCNS/05/FT BSE/05/FT Examinations for 2005-2006 / Semester

### Overview of Data Structures

UNIT 3 Concrete Data Types Classification of Data Structures Concrete vs. Abstract Data Structures Most Important Concrete Data Structures Arrays Records Linked Lists Binary Trees Overview of Data Structures

Chapter 4: Linked Lists Data Abstraction & Problem Solving with C++ Fifth Edition by Frank M. Carrano Preliminaries Options for implementing an ADT List Array has a fixed size Data must be shifted during

### 1. Constants. 2. Variables. 3. Reserved words or key words. 4. Constants. Character set in C

Character set in C We should use only the following characters in writing a C program. These characters can be combined to create C words. Alphabet: A, B, C, D.. Z, a, b, c, d..z Numeric digits: 0, 1,

### Data Structures Using C++ 2E. Chapter 5 Linked Lists

Data Structures Using C++ 2E Chapter 5 Linked Lists Doubly Linked Lists Traversed in either direction Typical operations Initialize the list Destroy the list Determine if list empty Search list for a given

### C Programming, Autumn 2013, Exercises for the Fifth Week. double maxi(double x, double y, double (*fp)(double z));

C Programming, Autumn 2013, Exercises for the Fifth Week 1. Wite a function double maxi(double x, double y, double (*fp)(double z)); which takes three parameters, two double values x and y, and a pointer

### M3-R4: PROGRAMMING AND PROBLEM SOLVING THROUGH C LANGUAGE

M3-R4: PROGRAMMING AND PROBLEM SOLVING THROUGH C LANGUAGE NOTE: IMPORTANT INSTRUCTIONS: 1. Question Paper in English and Hindi and Candidate can choose any one language. 2. In case of discrepancies in

### 406 memory pool memory allocation handle memory deallocation dynamic storage allocation

406 Chap. 12 Lists and Arrays Revisited 12.4 Memory Management Most of the data structure implementations described in this book store and access objects all of the same size, such as integers stored in

### SYSTEMS PROGRAMMING C++ INTRODUCTION

Faculty of Computer Science / Institute of Systems Architecture / Operating Systems SYSTEMS PROGRAMMING C++ INTRODUCTION Alexander Warg WHY C++? C++ is the language that allows to express ideas from the

### Lecture 12 Doubly Linked Lists (with Recursion)

Lecture 12 Doubly Linked Lists (with Recursion) In this lecture Introduction to Doubly linked lists What is recursion? Designing a node of a DLL Recursion and Linked Lists o Finding a node in a LL (recursively)

### C++ Keywords. If/else Selection Structure. Looping Control Structures. Switch Statements. Example Program

C++ Keywords There are many keywords in C++ that are not used in other languages. bool, const_cast, delete, dynamic_cast, const, enum, extern, register, sizeof, typedef, explicit, friend, inline, mutable,

### Generate C# source from UML class diagram in Visual Studio Written Date : February 23, 2010

Generate C# source from UML class diagram in Visual Studio Written Date : February 23, 2010 You can perform round-trip engineering in Visual Studio, to keep C# source code and class model in sync. In this

### ECE 250 Data Structures and Algorithms MIDTERM EXAMINATION 2008-10-23/5:15-6:45 REC-200, EVI-350, RCH-106, HH-139

ECE 250 Data Structures and Algorithms MIDTERM EXAMINATION 2008-10-23/5:15-6:45 REC-200, EVI-350, RCH-106, HH-139 Instructions: No aides. Turn off all electronic media and store them under your desk. If

### C++ Introduction to class and data abstraction

C++ Introduction to class and data abstraction 1 Data abstraction A data abstraction is a simplified view of an object by specifying what can be done with the object while hiding unnecessary details In

### Analysis of a Search Algorithm

CSE 326 Lecture 4: Lists and Stacks 1. Agfgd 2. Dgsdsfd 3. Hdffdsf 4. Sdfgsfdg 5. Tefsdgass We will review: Analysis: Searching a sorted array (from last time) List ADT: Insert, Delete, Find, First, Kth,

Lecture 11 Doubly Linked Lists & Array of Linked Lists In this lecture Doubly linked lists Array of Linked Lists Creating an Array of Linked Lists Representing a Sparse Matrix Defining a Node for a Sparse

### Chapter 13. Pointers and Linked Lists

Chapter 13 Pointers and Linked Lists Overview 13.1 Nodes and Linked Lists 13.2 Stacks and Queues Slide 13-2 13.1 Nodes and Linked Lists Nodes and Linked Lists n A linked list is a list that can grow and

### Molecular Dynamics Simulations with Applications in Soft Matter Handout 7 Memory Diagram of a Struct

Dr. Martin O. Steinhauser University of Basel Graduate Lecture Spring Semester 2014 Molecular Dynamics Simulations with Applications in Soft Matter Handout 7 Memory Diagram of a Struct Friday, 7 th March

### Introduction to C ++ : Questions

Introduction to C ++ : Questions Thomas Branch 28th November 204. A Tutorial Introduction. Getting Started Aim: Make sure the program compiles and runs, learn to get the program to output text. [Debug]

Unordered Linked Lists Derive class unorderedlinkedlist from the abstract class linkedlisttype Implement the operations search, insertfirst, insertlast, deletenode See code on page 292 Defines an unordered

### UNIVERSITI MALAYSIA SARAWAK KOTA SAMARAHAN SARAWAK PSD2023 ALGORITHM & DATA STRUCTURE

STUDENT IDENTIFICATION NO UNIVERSITI MALAYSIA SARAWAK 94300 KOTA SAMARAHAN SARAWAK FAKULTI SAINS KOMPUTER & TEKNOLOGI MAKLUMAT (Faculty of Computer Science & Information Technology) Diploma in Multimedia

### Programming for MSc Part I

Herbert Martin Dietze University of Buckingham herbert@the-little-red-haired-girl.org July 24, 2001 Abstract The course introduces the C programming language and fundamental software development techniques.

### Output: 12 18 30 72 90 87. struct treenode{ int data; struct treenode *left, *right; } struct treenode *tree_ptr;

50 20 70 10 30 69 90 14 35 68 85 98 16 22 60 34 (c) Execute the algorithm shown below using the tree shown above. Show the exact output produced by the algorithm. Assume that the initial call is: prob3(root)

### Short Notes on Dynamic Memory Allocation, Pointer and Data Structure

Short Notes on Dynamic Memory Allocation, Pointer and Data Structure 1 Dynamic Memory Allocation in C/C++ Motivation /* a[100] vs. *b or *c */ Func(int array_size) double k, a[100], *b, *c; b = (double

### Illustration 1: Diagram of program function and data flow

The contract called for creation of a random access database of plumbing shops within the near perimeter of FIU Engineering school. The database features a rating number from 1-10 to offer a guideline

### COMPUTER SCIENCE. Paper 1 (THEORY)

COMPUTER SCIENCE Paper 1 (THEORY) (Three hours) Maximum Marks: 70 (Candidates are allowed additional 15 minutes for only reading the paper. They must NOT start writing during this time) -----------------------------------------------------------------------------------------------------------------------

### DATA STRUCTURES USING C

DATA STRUCTURES USING C QUESTION BANK UNIT I 1. Define data. 2. Define Entity. 3. Define information. 4. Define Array. 5. Define data structure. 6. Give any two applications of data structures. 7. Give

### Singly Linked Lists and Chains

Chapter 4 Linked Lists Lecture 7-1 Singly Linked Lists and Chains Representing Chains in C++ Template Class Chain Circular Lists Available Space Lists Linked Stacks and Queues Polynomials Equivalence Classes

### Writing Portable Programs COS 217

Writing Portable Programs COS 217 1 Goals of Today s Class Writing portable programs in C Sources of heterogeneity Data types, evaluation order, byte order, char set, Reading period and final exam Important

### Lecture Notes on Binary Search Trees

Lecture Notes on Binary Search Trees 15-122: Principles of Imperative Computation Frank Pfenning André Platzer Lecture 17 October 23, 2014 1 Introduction In this lecture, we will continue considering associative

### C programming: exercise sheet L2-STUE (2011-2012)

C programming: exercise sheet L2-STUE (2011-2012) Algorithms and Flowcharts Exercise 1: comparison Write the flowchart and associated algorithm that compare two numbers a and b. Exercise 2: 2 nd order

### 10CS35: Data Structures Using C

CS35: Data Structures Using C QUESTION BANK REVIEW OF STRUCTURES AND POINTERS, INTRODUCTION TO SPECIAL FEATURES OF C OBJECTIVE: Learn : Usage of structures, unions - a conventional tool for handling a

### Chapter 3. Linked Lists. Data Structures and Algorithms in Java

Chapter 3 Linked Lists Data Structures and Algorithms in Java Objectives Discuss the following topics: Singly Linked Lists Doubly Linked Lists Circular Lists Skip Lists Self-Organizing Lists Sparse Tables

### The C Programming Language

The C Programming Language CS 1025 Computer Science Fundamentals I Stephen M. Watt University of Western Ontario The C Programming Language A high-level language for writing low-level programs Allows machine-independent

Arrays and Linked Lists Data Structures and Algorithms Acknowledgement: These slides are adapted from slides provided with Data Structures and Algorithms in C++ Goodrich, Tamassia and Mount (Wiley, 2004)

### KITES TECHNOLOGY COURSE MODULE (C, C++, DS)

KITES TECHNOLOGY 360 Degree Solution www.kitestechnology.com/academy.php info@kitestechnology.com technologykites@gmail.com Contact: - 8961334776 9433759247 9830639522.NET JAVA WEB DESIGN PHP SQL, PL/SQL

### Stacks. Linear data structures

Stacks Linear data structures Collection of components that can be arranged as a straight line Data structure grows or shrinks as we add or remove objects ADTs provide an abstract layer for various operations

### Sample Questions Csci 1112 A. Bellaachia

Sample Questions Csci 1112 A. Bellaachia Important Series : o S( N) 1 2 N N i N(1 N) / 2 i 1 o Sum of squares: N 2 N( N 1)(2N 1) N i for large N i 1 6 o Sum of exponents: N k 1 k N i for large N and k

Linked Data Structures 17 17.1 NODES AND LINKED LISTS 733 Nodes 733 Linked Lists 738 Inserting a Node at the Head of a List 740 Pitfall: Losing Nodes 743 Inserting and Removing Nodes Inside a List 743

### 1. Relational database accesses data in a sequential form. (Figures 7.1, 7.2)

Chapter 7 Data Structures for Computer Graphics (This chapter was written for programmers - option in lecture course) Any computer model of an Object must comprise three different types of entities: 1.

### 1. The First Visual C++ Program

1. The First Visual C++ Program Application and name it as HelloWorld, and unselect the Create directory for solution. Press [OK] button to confirm. 2. Select Application Setting in the Win32 Application

Linked Lists Ch 17 (Gaddis) Introduction to Linked Lists A data structure representing a A series of nodes chained together in sequence CS 3358 Summer I 2012 Jill Seaman - Each node points to one other

### Lecture 03 Bits, Bytes and Data Types

Lecture 03 Bits, Bytes and Data Types In this lecture Computer Languages Assembly Language The compiler Operating system Data and program instructions Bits, Bytes and Data Types ASCII table Data Types

### Algorithms and Data Structures Exercise for the Final Exam (17 June 2014) Stack, Queue, Lists, Trees, Heap

Algorithms and Data Structures Exercise for the Final Exam (17 June 2014) Stack, Queue, Lists, Trees, Heap Singly linked list (1) Data about exam results are stored into a singly linked list. Each list

### C Primer. Fall Introduction C vs. Java... 1

CS 33 Intro Computer Systems Doeppner C Primer Fall 2016 Contents 1 Introduction 1 1.1 C vs. Java.......................................... 1 2 Functions 1 2.1 The main() Function....................................

### Pallab Dasgupta. Linked Lists CS10001: Programming & Data Structures. Dept. of Computer Sc. & Engg., Indian Institute of Technology Kharagpur

Linked Lists CS10001: Programming & Data Structures Pallab Dasgupta Dept. of Computer Sc. & Engg., Indian Institute of Technology Kharagpur Arrays: pluses and minuses + Fast element access. -- Impossible

### Lecture Notes on Binary Search Trees

Lecture Notes on Binary Search Trees 15-122: Principles of Imperative Computation Frank Pfenning Lecture 17 March 17, 2010 1 Introduction In the previous two lectures we have seen how to exploit the structure

### The Relational Data Model

CHAPTER 8 The Relational Data Model Database One of the most important applications for computers is storing and managing information. The manner in which information is organized can have a profound effect

### The Basics of C Programming. Marshall Brain

The Basics of C Programming Marshall Brain Last updated: October 30, 2013 Contents 1 C programming 1 What is C?................................. 2 The simplest C program, I........................ 2 Spacing

### arrays C Programming Language - Arrays

arrays So far, we have been using only scalar variables scalar meaning a variable with a single value But many things require a set of related values coordinates or vectors require 3 (or 2, or 4, or more)

### PES Institute of Technology-BSC QUESTION BANK

PES Institute of Technology-BSC Faculty: Mrs. R.Bharathi CS35: Data Structures Using C QUESTION BANK UNIT I -BASIC CONCEPTS 1. What is an ADT? Briefly explain the categories that classify the functions

### Object Oriented Software Design II

Object Oriented Software Design II Introduction to C++ Giuseppe Lipari http://retis.sssup.it/~lipari Scuola Superiore Sant Anna Pisa February 20, 2012 G. Lipari (Scuola Superiore Sant Anna) C++ Intro February

### 1 Abstract Data Types Information Hiding

1 1 Abstract Data Types Information Hiding 1.1 Data Types Data types are an integral part of every programming language. ANSI-C has int, double and char to name just a few. Programmers are rarely content

### CS 261 Data Structures. Introduction to C Programming

CS 261 Data Structures Introduction to C Programming Why C? C is a simple language, C makes it easier to focus on important concepts C is a lower level, imperative language Lays groundwork for many other

### International Journal Of Engineering Research & Management Technology

International Journal Of Engineering Research & Management Technology ISSN: 2348-4039 September- 2014 Volume 1, Issue-5 Dynamic Implementation Using Linked List Karuna Department of Information and Technology

### Pointers and Strings. Objectives

5 Pointers and Strings Objectives To be able to use pointers. To be able to use pointers to pass arguments to functions by reference. To understand the close relationships among pointers, arrays and strings.

### Standard printing function in C is printf Prints everything numbers, strings, etc. May be complex to use. Standard C library is called libc

Arrays and Structs and Pointers, Oh My! Programming in C Input and output Using printf Standard input and output Pointers Arrays Structures Combining these things together Arrays and Structs and Pointers,

### PE1 Worksheet. 3) What are the three control structures for writing an algorithm in pseudocode?

PE1 Worksheet Problem solving 1) What are the four stages of problem solving by programming? What shall be done in each stage? Stage 1: Stage 2: Stage 3: Stage 4: 2) What is the top-down design strategy

### C for Java Programmers

C for Java Programmers CS 414 / CS 415 Niranjan Nagarajan Department of Computer Science Cornell University niranjan@cs.cornell.edu Original Slides: Alin Dobra Why use C instead of Java Intermediate-level

### Lecture 6. Randomized data structures Random number generation Skip lists: ideas and implementation Skip list time costs. Reading:

Lecture 6 Randomized data structures Random number generation Skip lists: ideas and implementation Skip list time costs Reading: Skip Lists: A Probabilistic Alternative to Balanced Trees (author William

### Chapter 18 Indexing Structures for Files. Indexes as Access Paths

Chapter 18 Indexing Structures for Files Indexes as Access Paths A single-level index is an auxiliary file that makes it more efficient to search for a record in the data file. The index is usually specified

### CSCI-1200 Data Structures Fall 2015 Lecture 10 Vector Iterators & Linked Lists

CSCI-1200 Data Structures Fall 2015 Lecture 10 Vector Iterators & Linked Lists Review from Lecture 9 Explored a program to maintain a class enrollment list and an associated waiting list. Unfortunately,

### 1. A linked list is a list of items, called nodes, in which the order of the nodes is determined by the address, called a link, stored in each node.

1138 Chapter 17: Linked Lists QUICK REVIEW 1. A linked list is a list of items, called nodes, in which the order of the nodes is determined by the address, called a link, stored in each node. 2. The pointer

1 ADTs,, Arrays, Linked Lists Outline and Required Reading: ADTs ( 2.1.2) Arrays ( 1.5) Linked Lists ( 4.3.1, 4.3.2) COSC 2011, Fall 2003, Section A Instructor: N. Vlajic Abstract Data Type (ADT) 2 abstract

### Quiz 4 Solutions EECS 211: FUNDAMENTALS OF COMPUTER PROGRAMMING II. 1 Q u i z 4 S o l u t i o n s

Quiz 4 Solutions Q1: What value does function mystery return when called with a value of 4? int mystery ( int number ) { if ( number

### Dynamic Memory Allocation

Dynamic Memory Allocation Dynamic memory allocation How to allocate memory for variables (esp. arrays/strings) during run time malloc(), calloc(), realloc(), and free() 1 Why dynamic memory allocation?

LINKED DATA STRUCTURES 1 Linked Lists A linked list is a structure in which objects refer to the same kind of object, and where: the objects, called nodes, are linked in a linear sequence. we keep a reference

### Data Structures. Topic #4

Topic #4 Today s Agenda Stack and Queue ADTs What are they Like Ordered Lists, are position oriented Use of Data Structures for Stacks and Queues arrays (statically & dynamically allocated) linear linked

### UNIVERSITY OF TORONTO FACULTY OF APPLIED SCIENCE AND ENGINEERING

UNIVERSITY OF TORONTO FACULTY OF APPLIED SCIENCE AND ENGINEERING APS 105 Computer Fundamentals Midterm Examination October 27, 2009 12:20 p.m. 1:50 p.m. Examiners: J. Anderson, T. Fairgrieve, H. Ghaderi,

### Example Solution to Exam in EDA150 C Programming

Example Solution to Exam in EDA150 C Programming Janurary 12, 2011, 14-19 Inga hjälpmedel! Examinator: Jonas Skeppstedt, tel 0767 888 124 30 out of 60p are needed to pass the exam. General Remarks A function

### Data Structures and Algorithms!

Data Structures and Algorithms! The material for this lecture is drawn, in part, from! The Practice of Programming (Kernighan & Pike) Chapter 2! 1 Motivating Quotation!!! Every program depends on algorithms

### BHARATHIAR UNIVERSITY: COIMBATORE CENTRE FOR COLLABORATION OF INDUSTRY AND INSTITUTIONS(CCII) CERTIFICATE IN ADVANCED PROGRAMMING C++ LANGUAGE

Certificate in Advanced Programming - C++ Language Page 1 of 7 BHARATHIAR UNIVERSITY: COIMBATORE 641046 CENTRE FOR COLLABORATION OF INDUSTRY AND INSTITUTIONS(CCII) CERTIFICATE IN ADVANCED PROGRAMMING C++

### Data Structures Using C++ 2E. Chapter 5 Linked Lists

Data Structures Using C++ 2E Chapter 5 Linked Lists Test #1 Next Thursday During Class Cover through (near?) end of Chapter 5 Objectives Learn about linked lists Become aware of the basic properties of

### Punctuation in C. Identifiers and Expressions. Identifiers. Variables. Keywords. Identifier Examples

Identifiers and Expressions CSE 130: Introduction to C Programming Spring 2005 Punctuation in C Statements are terminated with a ; Groups of statements are enclosed by curly braces: { and } Commas separate

### BM267 - Introduction to Data Structures

BM267 - Introduction to Data Structures 3. Elementary Data Structures Ankara University Computer Engineering Department BLM267 1 Objectives Learn about elementary data structures - Data structures that

### IC221: Systems Programming 06-Week Written Exam [SOLUTIONS]

IC221: Systems Programming 06-Week Written Exam [SOLUTIONS] February 12, 2014 Answer the questions in the spaces provided on the question sheets. If you run out of room for an answer, continue on the back

### (d) Ask the user enter a name. If the user says Freddy, force the user to keep entering a name until something else is received.

Problem 1 Write a complete C++ program that asks a user to enter their day and month of birth. If the user s birthday is March 14 th, the program wishes the user a Happy Birthday, otherwise it just says

### Linked Lists, Stacks, Queues, Deques. It s time for a chainge!

Linked Lists, Stacks, Queues, Deques It s time for a chainge! Learning Goals After this unit, you should be able to... Differentiate an abstraction from an implementation. Define and give examples of problems

### 4.3. Addition and Multiplication Laws of Probability. Introduction. Prerequisites. Learning Outcomes. Learning Style

Addition and Multiplication Laws of Probability 4.3 Introduction When we require the probability of two events occurring simultaneously or the probability of one or the other or both of two events occurring

### 2. Compressing data to reduce the amount of transmitted data (e.g., to save money).

Presentation Layer The presentation layer is concerned with preserving the meaning of information sent across a network. The presentation layer may represent (encode) the data in various ways (e.g., data

### C++ Mini-Course. Part 1: Mechanics Part 2: Basics Part 3: References Part 4: Const Part 5: Inheritance Part 6: Libraries Part 7: Conclusion. C Rulez!

C++ Mini-Course Part 1: Mechanics Part 2: Basics Part 3: References Part 4: Const Part 5: Inheritance Part 6: Libraries Part 7: Conclusion C Rulez! C++ Rulez! C++ Mini-Course Part 1: Mechanics C++ is a

### Efficient representation of integer sets

Efficient representation of integer sets Marco Almeida Rogério Reis Technical Report Series: DCC-2006-06 Version 1.0 Departamento de Ciência de Computadores & Laboratório de Inteligência Artificial e Ciência

### C++ DATA STRUCTURES. Defining a Structure: Accessing Structure Members:

C++ DATA STRUCTURES http://www.tutorialspoint.com/cplusplus/cpp_data_structures.htm Copyright tutorialspoint.com C/C++ arrays allow you to define variables that combine several data items of the same kind

### 22c:31 Algorithms. Ch3: Data Structures. Hantao Zhang Computer Science Department http://www.cs.uiowa.edu/~hzhang/c31/

22c:31 Algorithms Ch3: Data Structures Hantao Zhang Computer Science Department http://www.cs.uiowa.edu/~hzhang/c31/ Linear Data Structures Now we can now explore some convenient techniques for organizing

### INDEX. C programming Page 1 of 10. 5) Function. 1) Introduction to C Programming

INDEX 1) Introduction to C Programming a. What is C? b. Getting started with C 2) Data Types, Variables, Constants a. Constants, Variables and Keywords b. Types of Variables c. C Keyword d. Types of C

### Example 1/24. Example

Example CandC++. Misc. Library Features Gotchas Hints n Tips int **ppi int *pi int i char *pc char c Stephen Clark 5 University of Cambridge (heavily based on last year s notes (Andrew Moore) with thanks

### CSE 211: Data Structures Lecture Notes VII

CSE 211: Data Structures Lecture Notes VII LINKED LISTS In the previous lectures we have seen the representation of ordered lists using an array and sequential mapping. These representations had the property

### Questions 1 through 25 are worth 2 points each. Choose one best answer for each.

Questions 1 through 25 are worth 2 points each. Choose one best answer for each. 1. For the singly linked list implementation of the queue, where are the enqueues and dequeues performed? c a. Enqueue in

### Lecture 3. Using Classes and Objects

Lecture 3 Using Classes and Objects Using Classes and Objects We can create more interesting programs using predefined classes and related objects Chapter 3 focuses on: object creation and object references

### Data Structures and Algorithms Written Examination

Data Structures and Algorithms Written Examination 22 February 2013 FIRST NAME STUDENT NUMBER LAST NAME SIGNATURE Instructions for students: Write First Name, Last Name, Student Number and Signature where

### Basic Common Unix commands: Change to directory d

Basic Common Unix commands: cd d Change to directory d mkdir d rmdir d mv f1 [f2...] d mv d1 d2 ls [d] [f...] ls -1 [f...] vi [f] emacs [f] more f cp f1 f2 mv f1 f2 rm f gcc [-o f1] f2 gnuplot Create new

### INDEX ABOUT HASHING IN GENERAL

INDEX ABOUT HASHING IN GENERAL 1. URL... 2 2. INTRODUCTION.. 2 3. HASH TABLE STRUCTURE... 3 3.1 OPERATIONS 4 3.1.1 CREATE A TABLE 4 3.1.2 DELETE A TABLE 4 3.1.3 STRING LOOKUP.. 5 3.1.4 INSERT A STRING