Course Hero Logo

Systemoutprintlnrow index out of bounds return if

Course Hero uses AI to attempt to automatically extract content from documents to surface to you and others so you can study better, e.g., in search results, to enrich docs, and more. This preview shows page 237 - 241 out of 639 pages.

{System.out.println("row index out of bounds");return;}if (col_index < 0 && col+index > N){System.out.println("column index out of bounds");return;}sparse_array[row_index].store(col_index, val);}d)public void store(int row_index, int col_index, Object val){if (row_index < 0 && row_index > N){System.out.println("column index out of bounds");return;}if (col_index < 0 && col+index > N){System.out.println("row index out of bounds");return;}sparse_array[row_index].store(col_index, val);}
View AnswerAnswer: aExplanation: Each row in a sparse matrix acts as a sparse array, hence this row with the specifiedcol_index is the array and the specified position where the element is stored.10. What is the functionality of the following piece of code?public Object function(int row_index, int col_index){if (row_index < 0 || col_index > N){System.out.println("column index out of bounds");return;}return (sparse_array[row_index].fetch(col_index));}a) Store the element in the specified positionb) Get the element from the specified positionc) Alter the element in the specified positiond) Removes the element from the specified positionView AnswerAnswer: bExplanation: The fetch method of SparseArray class is called , the row specified by row_index makesit an array and the col_index denotes the specified position.11. Which of the following is the disadvantage of sparse matrices over normal matrices?a) Size
b) Speedc) Easily compressibled) Algorithm complexityView AnswerAnswer: d1. Which of the following is false?a) Suffix array is always sortedb) Suffix array is used in string matching problemsc) Suffix array is always unsortedd) Suffix array contains all the suffixes of the given stringView AnswerAnswer: cExplanation: Suffix array is always sorted as it contains all the suffixes of a string in sorted order.Suffix arrays are used to solve problems related to string, like string matching problems.2. Suffix array of the string “statistics” is ____________a) 2 8 7 4 9 0 5 1 6 3b) 2 7 4 9 8 0 5 1 6 3c) 2 4 9 0 5 7 8 1 6 3d) 2 8 7 0 5 1 6 9 4 3View AnswerAnswer: aExplanation: The suffix array of the string statistics will be:2 atistics8 cs7 ics
4 istics9 s0 statistics5 stics1 tatistics6 tics3 tisticsIn Suffix array, we only store the indices of suffixes. So, correct option is 2 8 7 4 9 0 5 1 6 3.3. Suffix array can be created by performing __________ traversal of a suffix tree.a) breadth-firstb) level orderc) depth-firstd) either breadth-first or level orderView AnswerAnswer: cExplanation: A suffix tree is a trie, which contains all the suffixes of the given string as their keys andpositions in the string as their values. So, we can construct a suffix array by performing the depth-first traversal of a suffix tree.4. Suffix array is space efficient and faster than the suffix tree.

Upload your study docs or become a

Course Hero member to access this document

Upload your study docs or become a

Course Hero member to access this document

End of preview. Want to read all 639 pages?

Upload your study docs or become a

Course Hero member to access this document

Term
Fall
Professor
NoProfessor
Tags

Newly uploaded documents

Show More

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture