ENEE 150: Intermediate Programming Concepts for Engineers Spring 2018 Handout #27. Midterm #2 Review

Similar documents
CSCI 171 Chapter Outlines

Strings in C. Professor Hugh C. Lauer CS-2303, System Programming Concepts

MPATE-GE 2618: C Programming for Music Technology. Syllabus

Class Information ANNOUCEMENTS

Kurt Schmidt. October 30, 2018

Linked Lists in C and C++

C & Data Structures syllabus

CS 241 Data Organization Binary Trees

ECE264 Spring 2013 Final Exam, April 30, 2013

PRINCIPLES OF OPERATING SYSTEMS

Aryan College. Fundamental of C Programming. Unit I: Q1. What will be the value of the following expression? (2017) A + 9

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

COMP 250 Midterm #2 March 11 th 2013

BBM 201 DATA STRUCTURES

COMP 524 Spring 2018 Midterm Thursday, March 1

Binary Search Tree 1.0. Generated by Doxygen Mon Jun :12:39

CSE 332 Spring 2013: Midterm Exam (closed book, closed notes, no calculators)

Writing an ANSI C Program Getting Ready to Program A First Program Variables, Expressions, and Assignments Initialization The Use of #define and

MULTIMEDIA COLLEGE JALAN GURNEY KIRI KUALA LUMPUR

CS 11 C track: lecture 5

CprE 288 Introduction to Embedded Systems Exam 1 Review. 1

Summer Final Exam Review Session August 5, 2009

211: Computer Architecture Summer 2016

Course Review for. Cpt S 223 Fall Cpt S 223. School of EECS, WSU

CP2 Revision. theme: dynamic datatypes & data structures

A6-R3: DATA STRUCTURE THROUGH C LANGUAGE

Linked Lists. .. and other linked structures. Pallab Dasgupta Professor, Dept. of Computer Sc & Engg INDIAN INSTITUTE OF TECHNOLOGY KHARAGPUR

ECE264 Fall 2013 Exam 3, November 20, 2013

Module 4: Index Structures Lecture 13: Index structure. The Lecture Contains: Index structure. Binary search tree (BST) B-tree. B+-tree.

Dynamic memory allocation (malloc)

CS251-SE1. Midterm 2. Tuesday 11/1 8:00pm 9:00pm. There are 16 multiple-choice questions and 6 essay questions.

Data Structure and Algorithm Homework #3 Due: 2:20pm, Tuesday, April 9, 2013 TA === Homework submission instructions ===

MIDTERM EXAMINATION Spring 2010 CS301- Data Structures

About this exam review

Dynamic memory allocation

17 February Given an algorithm, compute its running time in terms of O, Ω, and Θ (if any). Usually the big-oh running time is enough.

CS61, Fall 2012 Section 2 Notes

Array Initialization

Introduction to C. Zhiyuan Teo. Cornell CS 4411, August 26, Geared toward programmers

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

Introduction to C. Robert Escriva. Cornell CS 4411, August 30, Geared toward programmers

Computer Systems and Networks

CSE 250 Final Exam. Fall 2013 Time: 3 hours. Dec 11, No electronic devices of any kind. You can open your textbook and notes

Course Review. Cpt S 223 Fall 2009

CSE 332 Autumn 2013: Midterm Exam (closed book, closed notes, no calculators)

Lecture 15a Persistent Memory & Shared Pointers

Short Notes of CS201

Understanding Pointers

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

Run-time Environments - 3

C Review. MaxMSP Developers Workshop Summer 2009 CNMAT

CS PROGRAMMING & ATA STRUCTURES I. UNIT I Part - A

Chapter 19 Data Structures

V.S.B ENGINEERING COLLEGE DEPARTMENT OF INFORMATION TECHNOLOGY I IT-II Semester. Sl.No Subject Name Page No. 1 Programming & Data Structures-I 2

CS201 - Introduction to Programming Glossary By

CS 222: Pointers and Manual Memory Management

Introduction to Programming Using Java (98-388)

Review of the Lectures 21-26, 30-32

Character Strings. String-copy Example

C for C++ Programmers

Bachelor Level/ First Year/ Second Semester/ Science Full Marks: 60 Computer Science and Information Technology (CSc. 154) Pass Marks: 24

- 1 - Handout #22S May 24, 2013 Practice Second Midterm Exam Solutions. CS106B Spring 2013

Solution to CSE 250 Final Exam

ECE 15B COMPUTER ORGANIZATION

Example: Runtime Memory Allocation: Example: Dynamical Memory Allocation: Some Comments: Allocate and free dynamic memory

Lecture 4: Outline. Arrays. I. Pointers II. III. Pointer arithmetic IV. Strings

Heap Arrays. Steven R. Bagley

CSC 1600 Memory Layout for Unix Processes"

Quick review pointer basics (KR ch )

COSC345 Software Engineering. The Heap And Dynamic Memory Allocation

Programming. Pointers, Multi-dimensional Arrays and Memory Management

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

Recitation 2/18/2012

Lecture 8 Dynamic Memory Allocation

CA341 - Comparative Programming Languages

Introduction to C. Sean Ogden. Cornell CS 4411, August 30, Geared toward programmers

ECE551 Midterm Version 1

CS201 Some Important Definitions

C PROGRAMMING Lecture 5. 1st semester

CS2013 Course Syllabus Spring 2017 Lecture: Friday 8:00 A.M. 9:40 A.M. Lab: Friday 9:40 A.M. 12:00 Noon

Course Text. Course Description. Course Objectives. StraighterLine Introduction to Programming in C++

COSC 2007 Data Structures II Final Exam. Part 1: multiple choice (1 mark each, total 30 marks, circle the correct answer)

Memory Management. CS31 Pascal Van Hentenryck CS031. Lecture 19 1

Introduction to C. Ayush Dubey. Cornell CS 4411, August 31, Geared toward programmers

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

Cpt S 223 Course Overview. Cpt S 223, Fall 2007 Copyright: Washington State University

COP 3502 Section 2 Exam #2 Version A Spring /23/2017

COMP-202: Foundations of Programming. Lecture 13: Recursion Sandeep Manjanna, Summer 2015

CS 11 C track: lecture 6

PESIT Bangalore South Campus Department of MCA Course Information for

211: Computer Architecture Summer 2016

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

ESC101N: Fundamentals of Computing End-sem st semester

CS 270 Algorithms. Oliver Kullmann. Binary search. Lists. Background: Pointers. Trees. Implementing rooted trees. Tutorial

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

ECE264 Spring 2014 Exam 2, March 11, 2014

DATA STRUCTURE : A MCQ QUESTION SET Code : RBMCQ0305

CS2013 Course Syllabus Spring 2018 Lecture: Mon/Wed 2:00 P.M. 2:50 P.M. SH C259 Lab: Mon/Wed 2:50 P.M. 4:00 P.M. SH C259

DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING B.E SECOND SEMESTER CS 6202 PROGRAMMING AND DATA STRUCTURES I TWO MARKS UNIT I- 2 MARKS

PROGRAMMAZIONE I A.A. 2017/2018

Transcription:

ENEE 150: Intermediate Programming Concepts for Engineers Spring 2018 Handout #27 Midterm #2 Review 1 Time and Location The midterm will be given in class during normal class hours, 11:00a.m.-12:15p.m., on April 16th. 2 Format The midterm will be open-book (Kernighan and Ritchie, and Loukides and Oram), opennotes, closed everything else. In other words, you can bring any material that you have accumulated in class and recitation, but nothing else. Also, no calculators are allowed during the exam. 3 Scope The midterm will cover all the material introduced since the last midterm, given on February 28th essentially covering the material from lecture 11, given on March 5th, up and including lecture 20, given on April 11th. In other words, the midterm is not cumulative. Here s an outline of the topics covered in that period. Disclaimer: this is not meant to be an absolutely water-tight complete list of topics. If there is a topic not present in this list, it may still show up on the midterm. However, the list is a pretty good first-cut at what we have covered. I. String Review A. Character utilities 1. #include <ctype.h> 2. int isupper(int c) 3. int islower(int c) 4. char toupper(int c) 5. char tolower(int c) B. Strings: arrays of characters 1. Declaration and initialization a. "" syntax b. Termination by NULL or \0 character 2. Use in printf/scanf a. "%s" formatting placeholder 1

b. In scanf, no need for "&" syntax c. sprintf d. sscanf 3. String utilities a. #include <string.h> b. int strlen(char *s) c. strcpy(char *s1, char *s2) d. int strcmp(char *s1, char *s2) 1. parse.c a. "parsing" and delimiters b. Redirecting standard input and standard output c. Dictionary: array of strings or 2-D array of chars d. Forward declaration (use of "char *", "char []", and "char [][]") II. Pointer Arrays A. Arrays of pointers instead of data values 1. Pointers to pointers 2. Pointers to arrays B. Layout in memory C. Relationship to multi-dimensional arrays 1. Similarity in referencing / indexing 2. Difference in layout 3. Inner dimensions of arrays of pointers to arrays do not have to be of the same size 4. Difference in passing as arguments to functions D. Command-line arguments 1. Can pass arguments to main 2. main (int argc, char *argv[]) E. Code examples 1. args.c III. Structures A. Structure Basics 1. Declaration of structure template a. Use of typedef 2. Declaration of variables a. Combining variable and template declaration b. Initializing structs 3. Accessing structure members a. "." syntax b. Setting all fields of a structure to the corresponding fields of another structure in one statement 4. Pointers to structures a. The address of a structure is the address of the first element in the structure b. "->" syntax for derefencing a pointer to a struct 5. Arrays of structures a. Pointer arithmetic 6. Structures as function parameters a. Passing structs call by value 2

b. Passing structs call by reference c. Returning structs from functions B. Code examples 1. structure.c a. sizeof() 2. array_struct.c a. Sanity check command-line arguments b. Parsing from data file using fscanf c. Casting IV. Dynamic Memory Allocation A. malloc 1. Statically allocated vs dynamically allocated variables 2. 3 different data memory regions in C a. stack b. static data region c. heap 3. void *malloc(int) a. allocates int contiguous bytes on the heap b. returns a generic pointer, void *, to the first byte c. casting of generic pointers to specific pointer types d. returns NULL on failure e. #include <stdlib.h> 4. malloc d objects have no symbolic name; access only through pointers B. Related functions 1. void free(void *) a. Deallocates memory allocated by malloc b. Prevents memory leaks 2. void *calloc(int, int) a. Similar to malloc b. Separates sizeof and number of elements into different parameters 3. void *realloc(void *, int) a. Takes object pointed to by void * and changes its size to int 1. malloc.c 2. matadd.c a. Dynamic allocation of pointer arrays V. Linked Lists A. Basics 1. Self-referencing structures a. Declaration of link nodes b. Has a field, usually called next, that points to a struct of the same type 2. Data structure layout a. Multiple link nodes are chained together through next pointers b. Components: head pointer, link node, tail node with NULL next 3

3. Benefits a. Number of objects in the list can vary dynamically b. Insertion/deletion to/from arbitrary point in list is easy B. Operations 1. Traversal a. p = p->next 2. Insert a. Head insertion b. Middle insertion c. Tail insertion 3. Delete a. Head deletion b. Middle deletion: must find previous node C. Doubly-linked lists 1. Data structure layout (add a prev pointer to every self-referencing structure, and a tail pointer) 2. Traversal -- same as singly-linked list 3. Insert / delete a. Use prev pointer to access previous node s next pointer b. Only requires 1 pointer to search for insert/delete point, and to perform insertion/deletion D. Code examples 1. list.c 2. students-array2.c 3. students-list.c 4. students-double.c VI. Advanced Linked Data Structures A. Hash tables 1. Elements a. Key b. Hash function c. Bucket 2. Implementation a. Pointer array b. Given key, hash function maps to pointer array index or bucket B. Trees 1. Data structure layout a. Root pointer b. Each tree node has 0 or more children c. Root node has 0 parents, leaf nodes have 0 children d. Depth e. Height 2. Applications a. Storing hierarchical data b. Sorting 3. Ex: Binary search tree a. Tree with node fanout = 2 b. Nodes contain data, each with unique key 4

c. Left sub-tree of a node contains only nodes with keys < node s key. d. Right sub-tree of a node contains only nodes with keys > node s key. e. Both left and right sub-trees must also be BSTs 1. list-search.c 2. hash-search.c 3. tree-search.c VII. Recursion A. Principle of Induction 1. Inductive vs iterative formulation of problems a. Inductive: break solution to problem into a smaller problem of same type (and some primitive operations) b. Math formulas formulated in this way are called recurrences c. Base case and inductive case 2. Implement inductive formulation as a recursive function 3. Forward repetitions, followed by backward repetitions during return from inductions B. Classic recursive problems 1. Traveling salesman problem a. given N cities and cost for traveling from city i to j, find tour that visits all cities once with minimal cost b. (N-1)! possible tours c. Solve recursively by expanding partial tours 2. Tower of Hanoi a. Move N disks from source peg to destination peg, using middle peg as temporary space b. Solve recursively by moving N-1 disks from source to middle peg, Nth disk from source to destination peg, and N-1 disks from middle to destination peg 1. tree-search2.c 2. tsp.c 3. hanoi.c 5