Sample Theoretical Question What’s printed on the screen when the following programs are run? printing.c change_val.c And what does this function do? secret.c.

Slides:



Advertisements
Similar presentations
Programming with Alice Computing Institute for K-12 Teachers Summer 2011 Workshop.
Advertisements

Pointers Pointer is a variable that contains the address of a variable Here P is sahd to point to the variable C C 7 34……
MATH 224 – Discrete Mathematics
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Slide 7- 1 Overview 7.1 Introduction to Arrays 7.2 Arrays in Functions 7.3.
Priority Queues and Heaps. Overview Our last ADT: PriorityQueueADT A new data structure: heaps One more sorting algorithm: heapsort Priority Queues and.
Chapter 3 Stacks.
D IVIDE AND CONQUER STRATEGY, D ATA TYPE, A LGORITHM DESIGN AND PRACTICE. Week 13 Mr.Mohammed Rahmath.
CIS 101: Computer Programming and Problem Solving Lecture 7 Usman Roshan Department of Computer Science NJIT.
11.3 Function Prototypes A Function Prototype contains the function’s return type, name and parameter list Writing the function prototype is “declaring”
Programming Summary. Exercise – Remove Duplicates Download remove_duplicates_ex.c and implement the function void remove_duplicates(Node *head); remove_duplicates()
Algorithm Design Techniques: Induction Chapter 5 (Except Section 5.6)
 2003 Prentice Hall, Inc. All rights reserved. 1 Sorting Arrays Sorting data –Important computing application –Virtually every organization must sort.
CHAPTER 11 Searching. 2 Introduction Searching is the process of finding a target element among a group of items (the search pool), or determining that.
 2003 Prentice Hall, Inc. All rights reserved Sorting Arrays Sorting data –Important computing application –Virtually every organization must sort.
Sorting and Searching Algorithms Week 11 DSA. Recap etc. Arrays are lists of data 1-D, 2-D etc. Lists associated with searching and sorting Other structures.
Algorithms. Introduction Before writing a program: –Have a thorough understanding of the problem –Carefully plan an approach for solving it While writing.
Programming Arrays. Question Write a program that reads 3 numbers from the user and print them in ascending order. How many variables do we need to store.
Introduction to Problem SolvingS1.2.1 Bina © 1998 Liran & Ofir Introduction to Problem Solving Programming in C.
JAVA: An Introduction to Problem Solving & Programming, 5 th Ed. By Walter Savitch and Frank Carrano. ISBN © 2008 Pearson Education, Inc., Upper.
INTRO TO PROGRAMMING Chapter 2. M-files While commands can be entered directly to the command window, MATLAB also allows you to put commands in text files.
05/09/2015SJF L31 F21SF Software Engineering Foundations Formatting Converting numbers to Strings and vice versa Monica Farrow EM G30
IE 212: Computational Methods for Industrial Engineering
Recursion Chapter Nature of Recursion t Problems that lend themselves to a recursive solution have the following characteristics: –One or more.
JAVA: An Introduction to Problem Solving & Programming, 5 th Ed. By Walter Savitch and Frank Carrano. ISBN © 2008 Pearson Education, Inc., Upper.
Chapter 19 Searching, Sorting and Big O
Chapter 10 Applications of Arrays and Strings. Chapter Objectives Learn how to implement the sequential search algorithm Explore how to sort an array.
Chapter 10 Strings, Searches, Sorts, and Modifications Midterm Review By Ben Razon AP Computer Science Period 3.
Textbook Problem Java – An Introduction to Problem Solving & Programming, Walter Savitch, pp.219, Problem 08.
 2006 Pearson Education, Inc. All rights reserved Searching and Sorting.
LAB#7. Insertion sort In the outer for loop, out starts at 1 and moves right. It marks the leftmost unsorted data. In the inner while loop, in starts.
More While Loop Examples CS303E: Elements of Computers and Programming.
Algorithm Paradigms High Level Approach To solving a Class of Problems.
C++ for Engineers and Scientists Second Edition Chapter 11 Arrays.
CS Data Structures I Chapter 2 Principles of Programming & Software Engineering.
Survey of Sorting Ananda Gunawardena. Naïve sorting algorithms Bubble sort: scan for flips, until all are fixed Etc...
Fundamentals of Algorithms MCS - 2 Lecture # 15. Bubble Sort.
CMP 131 Introduction to Computer Programming Violetta Cavalli-Sforza Week 3, Lecture 1.
Scis.regis.edu ● CS-361: Control Structures Week 6 Dr. Jesús Borrego Lead Faculty, COS Regis University 1.
ITI 1120 Lab #5 Contributors: S. Boyd, R. Plesa, A. Felty, D. Inkpen, A. Williams, D. Amyot.
Data Structures & Algorithms
UNIT 5.  The related activities of sorting, searching and merging are central to many computer applications.  Sorting and merging provide us with a.
 2008 Pearson Education, Inc. All rights reserved JavaScript: Introduction to Scripting.
ALGORITHMS.
Homework #2: Functions and Arrays By J. H. Wang Mar. 24, 2014.
© Janice Regan, CMPT 128, February CMPT 128: Introduction to Computing Science for Engineering Students Recursion.
Python – May 12 Recap lab Chapter 2 –operators –Strings –Lists –Control structures.
LAB SESSION ONE DIMENSIONAL ARRAY.
1ADS Lecture 11 Stacks contd.. ADS Lecture 113 Singly Linked list-based Stack Top of stack is head of list (can insert elements at head in constant.
Count Controlled Loops (Nested) Ain’t no sunshine when she’s gone …
COMPUTER PROGRAMMING 2 ArrayLists. Objective/Essential Standard Essential Standard 3.00Apply Advanced Properties of Arrays Essential Indicator 3.02 Apply.
Static block can be used to check conditions before execution of main begin, Suppose we have developed an application which runs only on Windows operating.
Tutorial 9 Iteration. Reminder Assignment 8 is due Wednesday.
Irvine, Kip R. Assembly Language for x86 Processors 7/e, What's Next Linking to an External Library The Book's Link Library Stack Operations Defining.
For loop. Exercise 1 Write a program to have the user input three (3) numbers: (f)rom, (t)o, and (i)ncrement. Count from f to t in increments of i, inclusive.
4 - Conditional Control Structures CHAPTER 4. Introduction A Program is usually not limited to a linear sequence of instructions. In real life, a programme.
1 The Role of Algorithms in Computing. 2 Computational problems A computational problem specifies an input-output relationship  What does the.
 Last Lecture Reminder  Array Sorts  Exam Questions Examples  Open Questions ◦ Search Engines ◦ Operating Systems ◦ Multiple Files in Projects  Additional.
chap10 Chapter 10 Recursion chap10 2 Recursive Function recursive function The recursive function is a kind of function that calls.
LINKED LISTS.
DYNAMIC MEMORY ALLOCATION. Disadvantages of ARRAYS MEMORY ALLOCATION OF ARRAY IS STATIC: Less resource utilization. For example: If the maximum elements.
Sort & Search Algorithms
Stacks and Queues Chapter 4.
Stacks and Queues.
Review.
24 Searching and Sorting.
Exercise Solution First questions What's output What's input
Lets Play with arrays Singh Tripty
Lecture 10 CSE 331 Sep 21, 2012.
CS 1111 Introduction to Programming Spring 2019
Presentation transcript:

Sample Theoretical Question What’s printed on the screen when the following programs are run? printing.c change_val.c And what does this function do? secret.c

Parentheses checking Implement a function such that – Input – A string s that contains (among other things) parentheses Output – 1 if the parentheses’ nesting is legal, 0 otherwise For example – (()())() is legal, while ())() and (()(()) are not. Write a program that accepts a string from the user and checks etc’.

Dynamic structures Write a structure of a point in 2-D space and a distance function between two points Write a program that gets an array of points from the user and calculates the largest distance between a pair of points in the array The size of the array is given by the user before the points are read in Solution – max_distance.c

Split list Implement a linked list where each item simply contains an integer Input a number n from the user, and split the original list into two lists such that the first contains all the elements smaller than n, and the other contains all the others Display both linked lists on the screen

String alignment Implement a function such that – Input – two strings, s1 and s2 Output – 1 if s2 is a substring-with- insertions of s1 For example, if s1 = “abcde” and s2 = “abe”, then the function should return 1 Solution – string_align.c

Printing maximum 20 Write a program that accepts integers from the user until a -1 is entered The program then prints the maximum 20 numbers Not necessarily sorted! Solution – maximum_20.c

Printing maximum n Change the previous program so that the first number the user enters is the number of numbers she wants printed So if the first number is 5, the top 5 numbers will be printed Solution – maximum_n.c