Algorithm analysis and structures?
-
public class Structure <E extends Comparable<? super E>>{ private E[] d; public Structure() { d = getArray(1); } public void show() { show(0); } private void show(int p){ if( p < d.length && d[p] != null) { show(r(p)); show(l(p)); System.out.print(d[p] + " "); } } public void add(E obj) { int p = getPos(obj); if(p >= d.length) resize(); d[p] = obj; } public boolean present(E obj){ int p = getPos(obj); return p < d.length && d[p] != null; } private int getPos(E obj){ int p = 0; while(p < d.length && d[p] != null){ int dir = <*1>; if(dir < 0) p = l(p); else if(dir >0) p = r(p); else return p; } return p; } private E[] getArray(int size) { return (E[]) new Comparable[size]; } private void resize(){ E[] temp = getArray(d.length*2 + 1); for( int i = 0; i < d.length; i++) temp[i] = d[i]; d = temp; } private int l(int i) { return 2 * i + 1;} private int r(int i) { return 2 * i + 2;} } What kind of data structure is it? the answer choices were array based list stack linked list max heap binary search tree. public void fillCol(int n, Collection<Integer> col){ for(int i = 0; i < n; i++) col.add(i); } what is the big o of the method for linked list and treeset linked list: O(N), O(NlogN), or O(n^2) treeset same as above. A class that represents a graph uses an adjacency matrix to represent the connections between verticies. What are the space requirements for a graph that contains N nodes with an average of M connections per node? Pick the most restrictive correct answer. O(N^2), O(NM) O(N^2M) O(N) O(N^2+ log M) public void sort(List<Double> data){ int lim = data.size(); for(int i = 0; i < lim; i++){ int m = i; for(int j = i + 1; j < lim; j++) if(data.get(j) < data.get(m) ) m = j; data.set( i, data.set(m, data.get(i))); } } Big o for linked and arraylist
-
Answer:
Have you attempted any of this yet? Post your answers and we can double check them.
what at Yahoo! Answers Visit the source
Related Q & A:
- How would you transfer data between your data structures and databases?Best solution by Programmers
- How to find contour lines for Appel's Hidden Line Removal Algorithm?Best solution by Computer Science
- How does Lowe compute the "repeatability" of his SIFT Algorithm?Best solution by Stack Overflow
- What is the difference between principal component analysis and factor analysis?Best solution by Cross Validated
- What is the difference between situational analysis and a SWOT analysis?Best solution by Yahoo! Answers
Just Added Q & A:
- How many active mobile subscribers are there in China?Best solution by Quora
- How to find the right vacation?Best solution by bookit.com
- How To Make Your Own Primer?Best solution by thekrazycouponlady.com
- How do you get the domain & range?Best solution by ChaCha
- How do you open pop up blockers?Best solution by Yahoo! Answers
For every problem there is a solution! Proved by Solucija.
-
Got an issue and looking for advice?
-
Ask Solucija to search every corner of the Web for help.
-
Get workable solutions and helpful tips in a moment.
Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.