Computer Science 1 Study Union Practice Problems. What are the arguments to malloc? calloc? realloc? What do they do?

Similar documents
DYNAMIC MEMORY ALLOCATION AND DEALLOCATION

COP 3502 Spring 2018 Study Union Review

R13. II B. Tech I Semester Supplementary Examinations, May/June DATA STRUCTURES (Com. to ECE, CSE, EIE, IT, ECC)

1 P a g e A r y a n C o l l e g e \ B S c _ I T \ C \

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

Course Name: B.Tech. 3 th Sem. No of hours allotted to complete the syllabi: 44 Hours No of hours allotted per week: 3 Hours. Planned.

Table of Contents. Chapter 1: Introduction to Data Structures... 1

Course Review. Cpt S 223 Fall 2010

A6-R3: DATA STRUCTURE THROUGH C LANGUAGE

Cpt S 223 Fall Cpt S 223. School of EECS, WSU

Course Review. Cpt S 223 Fall 2009

Introduction p. 1 Pseudocode p. 2 Algorithm Header p. 2 Purpose, Conditions, and Return p. 3 Statement Numbers p. 4 Variables p. 4 Algorithm Analysis

End-Term Examination Second Semester [MCA] MAY-JUNE 2006

R10 SET - 1. Code No: R II B. Tech I Semester, Supplementary Examinations, May

First Semester - Question Bank Department of Computer Science Advanced Data Structures and Algorithms...

VALLIAMMAI ENGINEERING COLLEGE

PESIT Bangalore South Campus Department of MCA Course Information for

Course Review for Finals. Cpt S 223 Fall 2008

MLR Institute of Technology

APJ ABDUL KALAM TECHNOLOGICAL UNIVERSITY THIRD SEMESTER B.TECH DEGREE EXAMINATION, JULY 2017 CS205: DATA STRUCTURES (CS, IT)

17CS33:Data Structures Using C QUESTION BANK

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

Algorithms and programs, basic idea of pseudo-code.algorithm efficiency and analysis, time and space analysis of algorithms order notations.

12 Abstract Data Types

CP2 Revision. theme: dynamic datatypes & data structures

Computer Science Foundation Exam

INSTITUTE OF AERONAUTICAL ENGINEERING

INSTITUTE OF AERONAUTICAL ENGINEERING (Autonomous) Dundigal, Hyderabad

Summer Final Exam Review Session August 5, 2009

Prepared By: Ms. Nidhi Solanki (Assist. Prof.) Page 1

VALLIAMMAI ENGINEERING COLLEGE SRM Nagar, Kattankulathur

CS301 - Data Structures Glossary By

Total No. of Questions :09] [Total No. of Pages : 02. II/IV B.Tech. DEGREE EXAMINATIONS, NOV/DEC First Semester CSE/IT DATA STRUCTURES USING C

Friday Four Square! 4:15PM, Outside Gates

CS 445: Data Structures Final Examination: Study Guide

Code No: R Set No. 1

Data Structure Advanced

Syllabus for Bachelor of Technology. Computer Engineering. Subject Code: 01CE0301. Subject Name: Data Structure. B.Tech. Year - II

A6-R3: DATA STRUCTURE THROUGH C LANGUAGE

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

Computer Science Foundation Exam. Dec. 19, 2003 COMPUTER SCIENCE I. Section I A. No Calculators! KEY

MULTIMEDIA COLLEGE JALAN GURNEY KIRI KUALA LUMPUR

DHANALAKSHMI COLLEGE OF ENGINEERING Tambaram, Chennai DEPARTMENT OF ELECTRONICS AND COMMUNICATION ENGINEERING

Algorithm Class. C C++ DS JAVA DATA STRUCTURES TRAINING INSTITUTE KPHB HYDERABAD. Mobile:

Course goals. exposure to another language. knowledge of specific data structures. impact of DS design & implementation on program performance

ECE250: Algorithms and Data Structures Midterm Review

R10 SET - 1. Code No: R II B. Tech I Semester, Supplementary Examinations, May

ASSIGNMENTS. Progra m Outcom e. Chapter Q. No. Outcom e (CO) I 1 If f(n) = Θ(g(n)) and g(n)= Θ(h(n)), then proof that h(n) = Θ(f(n))

GUJARAT TECHNOLOGICAL UNIVERSITY COMPUTER ENGINEERING (07) / INFORMATION TECHNOLOGY (16) / INFORMATION & COMMUNICATION TECHNOLOGY (32) DATA STRUCTURES

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

CS-301 Data Structure. Tariq Hanif

FINALTERM EXAMINATION Fall 2009 CS301- Data Structures Question No: 1 ( Marks: 1 ) - Please choose one The data of the problem is of 2GB and the hard

Discuss the following operations on One-Dimensional array with algorithms.

Computer Science Foundation Exam

CS302 Data Structures using C++

DATA STRUCTURES USING C

Computer Science Foundation Exam

MIDTERM EXAMINATION Spring 2010 CS301- Data Structures

COP 3502 (Computer Science I) Test #3: Data Structures Date: 11/1/2013 VERSION A

Postfix (and prefix) notation

About this exam review

PROGRAMMING IN C++ (Regulation 2008) Answer ALL questions PART A (10 2 = 20 Marks) PART B (5 16 = 80 Marks) function? (8)

Hash Tables. CS 311 Data Structures and Algorithms Lecture Slides. Wednesday, April 22, Glenn G. Chappell

Data Structures in C++ Using the Standard Template Library

CS171 Midterm Exam. October 29, Name:

There are many other applications like constructing the expression tree from the postorder expression. I leave you with an idea as how to do it.

Cpt S 122 Data Structures. Data Structures

Lecture Notes for Advanced Algorithms

Computer Science Foundation Exam

Solved by: Syed Zain Ali Bukhari (BSCS)

DS ata Structures Aptitude

Draw a diagram of an empty circular queue and describe it to the reader.

CSE 373 APRIL 17 TH TREE BALANCE AND AVL

CS 206 Introduction to Computer Science II

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

DATA STRUCTURES THROUGH C++

1) What is the primary purpose of template functions? 2) Suppose bag is a template class, what is the syntax for declaring a bag b of integers?

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

SAURASHTRA UNIVERSITY

Assume you are given a Simple Linked List (i.e. not a doubly linked list) containing an even number of elements. For example L = [A B C D E F].

QUESTION BANK. Prepared by,mrs.d.maladhy AP/IT,RGCET. Page 1

Delhi Noida Bhopal Hyderabad Jaipur Lucknow Indore Pune Bhubaneswar Kolkata Patna Web: Ph:

Data Structures Through C. Student Workbook

Computer Science 210 Data Structures Siena College Fall Topic Notes: Trees

FORTH SEMESTER DIPLOMA EXAMINATION IN ENGINEERING/ TECHNOLIGY- MARCH, 2012 DATA STRUCTURE (Common to CT and IF) [Time: 3 hours

This is a set of practice questions for the final for CS16. The actual exam will consist of problems that are quite similar to those you have

Faculty of Science FINAL EXAMINATION COMP-250 A Introduction to Computer Science School of Computer Science, McGill University

Visit ::: Original Website For Placement Papers. ::: Data Structure

3137 Data Structures and Algorithms in C++

CS W3134: Data Structures in Java

Sample Question Paper

An Introduction to Trees

Data Structures Question Bank Multiple Choice

Programming Abstractions

MID TERM MEGA FILE SOLVED BY VU HELPER Which one of the following statement is NOT correct.

Revision Statement while return growth rate asymptotic notation complexity Compare algorithms Linear search Binary search Preconditions: sorted,

Reg. No. : Question Paper Code : 27157

DATA STRUCTURE : A MCQ QUESTION SET Code : RBMCQ0305

BRONX COMMUNITY COLLEGE of the City University of New York DEPARTMENT OF MATHEMATICS AND COMPUTER SCIENCE. Sample Final Exam

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

Transcription:

Study Union Review Jacob Cornett 1 Computer Science 1 Study Union Practice Problems!This may not be a comprehensive review of everything that will be on your exam and we may go over more during the session. Be sure to check your specific professor s study guides as there are a lot of professors teaching this course this semester and I cannot guarantee that I will cover the material that is on every exam. I apologize for any errors in the guide, I ll try to address those if there are any during the session. Memory Management: What are the arguments to malloc? calloc? realloc? What do they do? What are the differences between these functions? Use the following struct definition for the following question: typedef struct node{ int data; struct node *next; } What would be the code to create an array of type node*? What about a two-dimensional array of type node*?

Study Union Review Jacob Cornett 2 Runtime Analysis: Know the runtime/space complexity of any of the algorithms or data structures that you ve covered in your class including but not limited to: bubble, insertion, selection, merge, quick, radix and bucket sort, binary search tree and AVL tree insertion/deletion, hash table insertion/deletion, heap insertion/deletion, linked list insertion/deletion w/ or w/o a tail pointer, binary search, stack/queue operations, trie insertion/deletion. Empirical Runtime: Find the amount of time that it would take to run an O(n 2 ) algorithm with 10,000 elements if when the same algorithm is run on 1,000 elements the function takes 500ns to run. Evaluate the following recurrence relation using iterative substitution: T (n)=t ( n 2 )+ n 3 +1 Evaluate the following summations: n 2 i i=1

Study Union Review Jacob Cornett 3 n 1 5n 2 i=0 Binary Search: What is the runtime of binary search? What are some applications of binary search? Know how to code binary search up. Recursion: Write a recursive solution to find the nth Fibonacci number: int nfib(int n){ }

Study Union Review Jacob Cornett 4 Write a recursive solution that finds whether a string is a palindrome returning 1 if it is or 0 if it is not: int ispalindrome(char *string){ } Bonus: Write a recursive solution that finds the number of pairs of integers in an array that add up to a value greater than a target number. That is given an array {3, 5, 7, 9} and a target 10 the following pairs add up to a number greater than or equal to 10: {(3,7), (5,7), (3,9), (5,9), (7,9)} (Try this without the position parameter too Hint: use pointer arithmetic) int numberofpairs(int *awesomenumbers, int position){ }

Study Union Review Jacob Cornett 5 Try and find the recurrence relations of the previous functions. Use these to find the run-times of the previous functions. Linked Lists: Write a function that takes the head to a linked list and inserts an element at the head of the list, at the end of the list. Write one that takes the head and tail of a linked list and inserts at the end of the list. Why do we keep a tail pointer?

Study Union Review Jacob Cornett 6 Bonus: Write a function that sorts a linked list and returns the new head. (Use any method you wish to sort the linked list). node *sortll(node *head){ } Stacks: Use a stack to convert the following postfix notation to infix: 5 3 + 4 2 3 * - 9 5 - * /

Study Union Review Jacob Cornett 7 Use a stack to convert the following infix notation to postfix ((9/3) + ((2-1) * 4)) / 7 What is the runtime for the push operation? What about pop? Queues: What are some situations where we would use a queue? What is the runtime of the enqueue and dequeue function if we keep a head and tail pointer?

Study Union Review Jacob Cornett 8 Trace through a breadth first search of the following BST using a queue Show the operations that happen at each step as well as the status of the queue after each enqueue/dequeue operation. 59 / \ 25 72 / \ / \ 9 36 62 84 Sorting: Know how to code up bubble, selection and insertion sort. Know how to trace through bucket, radix, merge and quick sort. Know the logic behind these sorts you may not have to code them up but you should be able to know how they work. Know the runtime and space complexity of these sorts Yes, some of them are not O(n) space complexity. Attempt to trace through the following sorting algorithms using this set of integers: 15, 9, 27, 4, 19, 20, 18, 50, 46, 79 Bubble:

Study Union Review Jacob Cornett 9 Insertion: Selection: Merge: Quick: Bucket:

Study Union Review Jacob Cornett 10 Sort the following set of integers using radix sort: 536, 249, 542, 539, 638, 248, 492, 875

Study Union Review Jacob Cornett 11 This page intentionally left blank for some crazy cool tricks that you may want to know.

Study Union Review Jacob Cornett 12 Binary Search Trees, AVL Trees, Heaps: What is a tree? What is a binary tree? What is a binary search tree? When do we say a BST is self balancing? What is the average height of a BST? What is the best/worst case insert runtime of a BST? Why? What about an AVL tree? When do we say a tree is full? Complete? Perform the following operations on a BST that is not self-balancing: Give the preorder, inorder and postorder traversals of the final tree Insert(26) Insert(30) Insert(15) Insert(22) Delete(15) Insert(36) Insert(20) Insert(23) Insert(14) Delete(22)

Study Union Review Jacob Cornett 13 Perform the following operations on a BST that is self balancing (an AVL tree): Give the preorder, inorder and postorder traversals of the final tree Insert(46) Insert(30) Insert(52) Insert(36) Insert(40) Insert(58) Insert(44) Insert(32) Insert(41) Insert(22) Insert(34) Delete(36) Delete(58) Delete(52)

Study Union Review Jacob Cornett 14 Tries: What does the trienode struct look like? Insert the following words into a trie: Muffin Mulligan Mufasa Cupcake Chess Cheap Coffee Bulwark Bullion Bastion What is the best/worst/average case runtime for insertion into a trie? What about deletion from a trie?what is the runtime to print every word in the trie?

Study Union Review Jacob Cornett 15 Hash Tables: What do we like the length of our hash table to be? When should we expand a hash table? What were the three types of probing we saw for hash tables? What are the benefits and drawbacks of these probing techniques? How did we fix some of the problems with some of those probing techniques? If we have an efficient hash table, what is the average case lookup in the hash table? Base Conversion: Convert 24 10 to base 2 Convert 01001001 2 to base 10 Convert 89AC 16 to base 2

Study Union Review Jacob Cornett 16 Bitwise Operators: What are the three main binary(two operands) bitwise operators? What is the main unary (one operand) bitwise operator? Use those three main binary operators on the following two 2s complement binary numbers: 0011 0110 0101 1101 0110 1011 Now negate the second binary number (Hint: there s something tricky going on here) What are the two types of shifts (not directions)? Do a shift left 2 and a shift right 2 with both of these on the second binary number from before. Be familiar with shift notation ( 01001 << 3 means shift 01001 left 3 bits and 01001 >> 3 means shift right 3 bits).

Study Union Review Jacob Cornett 17 Backtracking: What are some situations where we use backtracking? Do you think you could trace through a maze using backtracking? Could you trace a small nqueens problem using backtracking? What is the basic format for a backtracking algorithm? Are they usually recursive or iterative? What kind of search would we say a backtracking algorithm follows? What is the other kind of search? My list of excellent test-taking tips for the final and the foundation exam: CS1 is a very difficult class for a lot of people, it s a large ramp up in difficulty from Intro to C and it can seem difficult to mash all of that knowledge into your head. Knowing this though, try not to memorize as much as possible. Knowing concepts will be much more beneficial to you both now and in the long run. When taking your exam try not to focus too much on that really difficult problem that seems impossible to solve in the time that you re allotted initially. Read that problem, think on it a bit then move on to problems that you know you can do. Often times you ll find that when you return to that difficult question after a bit you ll have new insight. Obviously if you know you can solve it then go ahead and solve it but don t be afraid to leave the monstrous questions for a bit. Also, don t freak out, I guarantee freaking out will do more harm than good. Those absolutely hideously monstrous problems are meant to be difficult and require thought. Start by going through the data structures and algorithms you ve learned that can be used to solve the problem and then begin thinking about how to implement them. Think about code you ve seen before that s similar to the solution you re looking for. Good luck and may your programs always compile on the first attempt.