



Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Community
Ask the community for help and clear up your study doubts
Discover the best universities in your country according to Docsity users
Free resources
Download our free guides on studying techniques, anxiety management strategies, and thesis advice from Docsity tutors
A comprehensive overview of key concepts in computer science, including data types, abstract data types, algorithms, and code examples. It covers topics such as algorithm analysis, cost models, and the implementation of various algorithms in java. Suitable for students studying computer science at the university level.
Typology: Exams
1 / 7
This page cannot be seen from the preview
Don't miss anything!
data type - ✔✔A set of values and a set of operations on those values Abstract data type (ADT) - ✔✔A data type whose representation is hidden from the client. Identity 4 ADTs we have discussed - ✔✔Int, double, boolean, string Java Interface - ✔✔a collection of abstract methods and constants Tilde approximation - ✔✔Throw away low-order terms that complicate formulas and represent a negligible contribution to values of interest Cost Model - ✔✔The basic operations used by algorithms we are studying to solve the problem at hand. What is the point if algorithm analysis? - ✔✔Required resources of an algorithm to solve specific computational problem. public static double valRange (double[] list) { - ✔✔double cmin = list[0]; double cmax = list[0];
for (int i = 1; i < list.length; i++) { if (list[i] > cmax) cmax = list[i]; if (list[i] < cmin) cmin = list[i]; } return cmax - cmin; } public static int posOfLargestElementLtOeT( double limit, double[] list) {
return false; public static int numDuplicates (char[] list) { - ✔✔int sum = 0; for(int i = 1; i < list.length; i++) { if(list[i] == list[i-1]) sum++; } return sum; public static char[] removeDuplicates (char[] list) { - ✔✔char[] ans = new char[list.length-numDuplicates(list)]; int counter = 0; for(int i = 0; i < list.length; i++) { if (i == 0 || list[i] != list[i-1]) { ans[counter++] = list[i]; } } return ans; public static int sumOfOdds (int[] a) { - ✔✔int result = 0; int i = 0; while (i < a.length) { if ( a[i] %2 == 1)
result = result + a[i]; i = i + 1; } return result; public static void reverseIterative (int[] a) { - ✔✔int hi = a.length - 1; int lo = 0; while (lo < hi) { int loVal = a[lo]; int hiVal = a[hi]; a[hi] = loVal; a[lo] = hiVal; lo = lo + 1; hi = hi - 1; public static void reverseArrayHelper(int[] a, int start, int end) { - ✔✔int temp; if(start>=end) return; temp = a[start]; a[start] = a[end]; a[end] = temp;
if (n == 0) // base case result = 0; else result = a[n] + sumOfArray(a[n-1]); return result; Reverse the queue of q1 - ✔✔Stack s1 = new Stack(); while(!q1.isEmpty()) { int item = q1.dequeue(); s1.push(item); } while(s1.isEmpty()) { int item = s1.pop(); q1.enqueue(item); }