












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
These are the Lecture Slides of Algorithms and Applications in Java which includes Greedy Method, Divide and Conquer, Dynamic Programming, Backtracking, Branch and Bound, Integer Programming, Neural Networks, Genetic Algorithms, Tabu Search etc.Key important points are: Data Representation Methods, Simulated Pointer, Linear List, Array Representation, One-Dimensional Array, Right to Left Mapping, Wrap Around Mapping, Representation Used in Text, Data Type
Typology: Slides
1 / 20
This page cannot be seen from the preview
Don't miss anything!
a b c d e
a b c d e
d e a b c
a b c d e
a g b c d e
Increasing Array Length Length of array element[] is 6. a b c d e f newArray = new Object[15]; First create a new and larger array
Increasing Array Length Now copy elements from old array to new one. a b c d e f a b c d e f
public static Object [] changeLength(Object [] a, int newLength) { Object [] newArray = new Object [newLength]; System.arrayCopy(…); return newArray; } Integer [] a = new Integer [10]; …. a = (Integer []) changeLength(a, 100); // erroneous
Space Complexity newArray = new char[7]; space needed = 2 * newLength – 1 = 2 * maxListSize – 1 element[6] a b c d e f
Array Doubling Double the array length. a b c d e f newArray = new char[12]; a b c d e f Time for n adds goes up by Theta(n). Space needed = 1.5newLength. Space needed <= 3maxListSize – 3
How Big Should The New Array Be? Resizing by an additive constant c requires at most (maxListSize – 1) + (maxListSize – 1 + c) = 2 * (maxListSize – 1) + c space. Resizing by any constant factor new length = c * old length requires at most (1+c) * (maxListSize -1) space_._