Question Hot Seat public MyConstructor (int a, int b) { index = a+b; } A.Parameters B.Class Name C.Body D.Modifier Please put match these choices to these.

Slides:



Advertisements
Similar presentations
1 Various Methods of Populating Arrays Randomly generated integers.
Advertisements

Skip List & Hashing CSE, POSTECH.
Chapter 6: Arrays Java Software Solutions for AP* Computer Science
©TheMcGraw-Hill Companies, Inc. Permission required for reproduction or display. Chapter 11: Sorting and Searching  Searching Linear Binary  Sorting.
Chapter 11 Sorting and Searching. Topics Searching –Linear –Binary Sorting –Selection Sort –Bubble Sort.
Programming with Collections Collections in Java Using Arrays Week 9.
© The McGraw-Hill Companies, 2006 Chapter 5 Arrays.
CS107 Introduction to Computer Science Lecture 5, 6 An Introduction to Algorithms: List variables.
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.
©The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 4 th Ed Chapter Chapter 11 Sorting and Searching.
Arrays Data Structures - structured data are data organized to show the relationship among the individual elements. It usually requires a collecting mechanism.
Chapter 7 (Part 2) Sorting Algorithms Merge Sort.
C++ for Engineers and Scientists Third Edition
Chapter 8 Arrays and Strings
Introducing Hashing Chapter 21 Copyright ©2012 by Pearson Education, Inc. All rights reserved.
CS 106 Introduction to Computer Science I 10 / 15 / 2007 Instructor: Michael Eckmann.
CS 106 Introduction to Computer Science I 10 / 16 / 2006 Instructor: Michael Eckmann.
- SEARCHING - SORTING.  Given:  The array  The search target: the array element value we are looking for  Algorithm:  Start with the initial array.
Introduction to Java Appendix A. Appendix A: Introduction to Java2 Chapter Objectives To understand the essentials of object-oriented programming in Java.
CS1101: Programming Methodology Aaron Tan.
Chapter 7: Arrays. In this chapter, you will learn about: One-dimensional arrays Array initialization Declaring and processing two-dimensional arrays.
For each primitive type there is a wrapper class for storing values of that type: Double d = new Double(29.95); Wrapper Classes Wrapper objects can be.
© 2000 McGraw-Hill Introduction to Object-Oriented Programming with Java--WuChapter Chapter 10 Sorting and Searching.
INFO Problem Solving and Programming Logic INFO Problem Solving and Programming Logic Arrays Sorting.
Lists in Python.
C++ Basics Structure of a Program. C++ Source Code Plain text file Typical file extension .CPP Must compile the C++ source code without errors before.
Chapter 8 Arrays and Strings
Chapter 10 Strings, Searches, Sorts, and Modifications Midterm Review By Ben Razon AP Computer Science Period 3.
Chapter 11 Arrays Continued
©The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 4 th Ed Chapter Chapter 11 Sorting and Searching.
+ ARRAYS - SEARCHING - SORTING Dr. Soha S. Zaghloul updated by Rasha M. AL_Eidan 2015.
EGR 2261 Unit 8 One-dimensional Arrays  Read Malik, pages in Chapter 8.  Homework #8 and Lab #8 due next week.  Quiz next week.
ARRAYS 1 Week 2. Data Structures  Data structure  A particular way of storing and organising data in a computer so that it can be used efficiently 
The while Loop Syntax while (condition) { statements } As long condition is true, the statements in the while loop execute.
Topic 25 - more array algorithms 1 "To excel in Java, or any computer language, you want to build skill in both the "large" and "small". By "large" I mean.
The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL Adrian Ilie COMP 14 Introduction to Programming Adrian Ilie July 19, 2005.
C++ for Engineers and Scientists Second Edition Chapter 11 Arrays.
By: Lokman Chan Recursive Algorithm Recursion Definition: A function that is define in terms of itself. Goal: Reduce the solution to.
Data Structure Introduction.
©The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 4 th Ed Chapter Chapter 11 Searching and Sorting.
CS1101: Programming Methodology
Review Binary Numbers Bit : 0 or 1 Byte: 8 bites 256 different values 2 8 KB : 1024 bytes 2 10 bytes MB : 1024 * 1024 bytes 2 10 * 2 10 (2 20 ) bytes GB.
Week # 2: Arrays.  Data structure  A particular way of storing and organising data in a computer so that it can be used efficiently  Types of data.
CSCI 51 Introduction to Programming March 12, 2009.
Java Methods Big-O Analysis of Algorithms Object-Oriented Programming
Algorithms Java Methods A & AB Object-Oriented Programming and Data Structures Maria Litvin ● Gary Litvin Copyright © 2006 by Maria Litvin, Gary Litvin,
ALGORITHMS.
Array Search & Sort (continues). On the fly questions Array declaration: int[] a, b, c; 1. a is an array of integers, b and c are two integers 2. a, b,
Liang, Introduction to Programming with C++, Second Edition, (c) 2010 Pearson Education, Inc. All rights reserved Chapter 6 Arrays.
Composition When one class contains an instance variable whose type is another class, this is called composition. Instead of inheritance, which is based.
Arrays. The array data structure Array is a collection of elements, that have the same data type Integers (int) Floating point numbers (float, double)
©The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 4 th Ed Chapter Searching When we maintain a collection of data,
1 Chapter 13-2 Applied Arrays: Lists and Strings Dale/Weems.
Sorting and Searching. Searching  Problem definition: Given a value X, return the index of X in the array if such X exist. Otherwise, return NOT_FOUND(-1).
Visual C++ Programming: Concepts and Projects Chapter 8A: Binary Search (Concepts)
Course Code #IDCGRF001-A 5.1: Searching and sorting concepts Programming Techniques.
Aside: Running Supplied *.java Programs Just double clicking on a *.java file may not be too useful! 1.In Eclipse, create a project for this program or.
1. Searching The basic characteristics of any searching algorithm is that searching should be efficient, it should have less number of computations involved.
Chapter 3: Sorting and Searching Algorithms 3.1 Searching Algorithms.
Arrays Declaring arrays Passing arrays to functions Searching arrays with linear search Sorting arrays with insertion sort Multidimensional arrays Programming.
VISUAL C++ PROGRAMMING: CONCEPTS AND PROJECTS Chapter 8A Binary Search (Concepts)
Using recursion for Searching and Sorting
Recitation 13 Searching and Sorting.
Introduction to Programming
Arrays An Array is an ordered collection of variables
© A+ Computer Science - Arrays and Lists © A+ Computer Science -
Data Structures (CS212D) Week # 2: Arrays.
Arrays Part 2.
Revision of C++.
Presentation transcript:

Question Hot Seat public MyConstructor (int a, int b) { index = a+b; } A.Parameters B.Class Name C.Body D.Modifier Please put match these choices to these boxes from left to right DBAC

Ask Audience Call a friend Which of the following is invalid identifier? a. GoodVarb. $Good123Var c. Good_123Vard. %Good$Var

Ask Audience Call a friend How would you define a Java array? a. GoodVarb. $Good123Var a. Good_123Vara. %Good$Var

Ask Audience Call a friend How would you define a Java array ? a. a collection of data values of different types b. a collection of data values of the same type c. a collection of characters that incidentally form a string d. a collection of primitive data types

Ask Audience Call a friend How would you define a Java array? a. a collection of data values of different types b. a collection of data values of the same type c. a collection of characters that incidentally form a string d. a collection of primitive data types

Ask Audience Call a friend What are the two ways that a Java array can be declared? a. [ ] ; ; b. [ ]; ;[ ] c. [ ] ; [ ] ; d. [ ] ; [ ];

Ask Audience Call a friend What are the two ways that a Java array can be declared? a. [ ] ; ; b. [ ]; ;[ ] c. [ ] ; [ ] ; d. [ ] ; [ ];

Ask Audience Call a friend Which of the following declares an array of integers of size 20? a. int[ ] a = int[20]; b. int[ ] a = new int[20]; c. int a = new int[19]; d. int a[ ] = new int[19];

Ask Audience Call a friend Which of the following declares an array of integers of size 20? a. int[ ] a = int[20]; b. int[ ] a = new int[20]; c. int a = new int[19]; d. int a[ ] = new int[19];

Ask Audience Call a friend How would we access the 12th element of the array, x? a. x(12); b. x(11); c. x[12]; d. x[11];

Ask Audience Call a friend How would we access the 12th element of the array, x? a. x(12); b. x(11); c. x[12]; d. x[11];

Ask Audience Call a friend Why are loops particularly useful for array operations? a. Because loops easily traverse through the indexes of the array. b. Because loops solve problems that otherwise would not be solvable without them. c. Because loops take less time to run than conventional coding without loops d. Loops do not aid in the processing of arrays.

Ask Audience Call a friend Why are loops particularly useful for array operations? a. Because loops easily traverse through the indexes of the array. b. Because loops solve problems that otherwise would not be solvable without them. c. Because loops take less time to run than conventional coding without loops d. Loops do not aid in the processing of arrays.

Ask Audience Call a friend What does the following program do? double x = 0, unknown; for (int j = 0; j < someArray.length; j++){ x+=someArray[j]; } unknown = x /someArray.length; a. Computes the sum of the doubles in the array, someArray. b. Deletes all the doubles in the array, someArray. c. Computes the average of all the doubles in the array, someArray d. Computes the dot product of all the doubles in the array, someArray.

Ask Audience Call a friend What does the following program do? double x = 0, unknown; for (int j = 0; j < someArray.length; j++){ x+=someArray[j]; } unknown = x /someArray.length; a. Computes the sum of the doubles in the array, someArray. b. Deletes all the doubles in the array, someArray. c. Computes the average of all the doubles in the array, someArray d. Computes the dot product of all the doubles in the array, someArray.

Ask Audience Call a friend Given a value X, return the index of X in the array, if such X exists. Otherwise, return NOT_FOUND. We assume there are no duplicate entries in the array. What are the two possible outcomes in this problem? a. linear search and binary search b. -1 and X c. an index and a value d. successful and unsuccessful

Ask Audience Call a friend Given a value X, return the index of X in the array, if such X exists. Otherwise, return NOT_FOUND. We assume there are no duplicate entries in the array. What are the two possible outcomes in this problem? a. linear search and binary search b. -1 and X c. an index and a value d. successful and unsuccessful

Ask Audience Call a friend When would a programmer be forced to pick a linear search over a binary search? a. When the items in the array are in ascending order b. When the items in the array are in descending order c. When the items in the array are unsorted d. Linear search is never a better choice than binary search.

Ask Audience Call a friend When would a programmer be forced to pick a linear search over a binary search? a. When the items in the array are in ascending order b. When the items in the array are in descending order c. When the items in the array are unsorted d. Linear search is never a better choice than binary search.

Ask Audience Call a friend Which of the following best describes the protocol for a selection sort? a.Identify the largest element. Place the element at the beginning of a target list Repeat b. Identify the median of the list Split the list into two halves, those smaller and those larger than the median Perform the same sort on each of the smaller halves c. Identify the smallest element of the list Place the element in the beginning of the target list Repeat d. Identify the median element of the list Place the element in the beginning of a target list Repeat

Ask Audience Call a friend Which of the following best describes the protocol for a selection sort? a.Identify the largest element. Place the element at the beginning of a target list Repeat b. Identify the median of the list Split the list into two halves, those smaller and those larger than the median Perform the same sort on each of the smaller halves c. Identify the smallest element of the list Place the element in the beginning of the target list Repeat d. Identify the median element of the list Place the element in the beginning of a target list Repeat

Ask Audience Call a friend What is the biggest number of computations made for a binary search on a sorted array of size 64? a)3b)5 c) d)8

Ask Audience Call a friend What is the biggest number of computations made for a binary search on a sorted array of size 64? a)3b)5 c) d)8

Ask Audience Call a friend What is wrong with the following code? int product = 0, count=0; while (product < 2500){ product *= 5; count++; } a. the syntax of the while statement is invalid b. the operator, *=, does not exist. c. it has an infinite loop d. the count variable is initialized incorrectly.

Ask Audience Call a friend What is wrong with the following code? int product = 0, count=0; while (product < 2500){ product *= 5; count++; } a. the syntax of the while statement is invalid b. the operator, *=, does not exist. c. it has an infinite loop d. the count variable is initialized incorrectly.

Ask Audience Call a friend Assume you had a class BankInfo that contained three data members: accountNumber, pinNumber, and name. The data member name must be searchable by other classes. What access modifiers would you apply to these members? a. make accountNumber private, pinNumber private, and name public b. make accountNumber public, pinNumber private, and name public c. make them all private d. make them all public

Ask Audience Call a friend Assume you had a class BankInfo that contained three data members: accountNumber, pinNumber, and name. The data member name must be searchable by other classes. What access modifiers would you apply to these members? a. make accountNumber private, pinNumber private, and name public b. make accountNumber public, pinNumber private, and name public c. make them all private d. make them all public

Ask Audience Call a friend What is the difference in path name specification between the UNIX and Windows operating systems? a. There are no.exe files in UNIX but there are.exe files in Windows b. UNIX allows for spaces in file and directory names while Windows does not. c. UNIX separates directories from subdirectories with forward slashes while Windows separates directories with backslashes d. There is no difference

Ask Audience Call a friend What is the difference in path name specification between the UNIX and Windows operating systems? a. There are no.exe files in UNIX but there are.exe files in Windows b. UNIX allows for spaces in file and directory names while Windows does not. c. UNIX separates directories from subdirectories with forward slashes while Windows separates directories with backslashes d. There is no difference

Ask Audience Call a friend Assume you want to read the contents of a file and display to the monitor. Which file I/O classes can we use to accomplish this? a. FileInputStream or FileOutputStream b. FileInputStream or DataInputStream c. FileOutputStream or DataOutputStream d. DataInputStream or DataOutputStream

Ask Audience Call a friend Assume you want to read the contents of a file and display to the monitor. Which file I/O classes can we use to accomplish this? a. FileInputStream or FileOutputStream b. FileInputStream or DataInputStream c. FileOutputStream or DataOutputStream d. DataInputStream or DataOutputStream

Ask Audience Call a friend

Ask Audience Call a friend