Data Structure Review 2

Source: Internet
Author: User

1, A non-empty generalized table footer ( only the child table )

Parsing: (1The data structure defines the table header and footer of a generalized table as follows:  
If the generalized tablels=(a1,a2...an) is not empty, theA1is aLSthe table header, the remaining elements of the table (A2,a3,.. an) is calledLSend of the table.   
By definition, the non-null generalized table the table header is an element that can be an atom or a child table, and the end of the table must be a child table. For example: Ls= (A, b),the table header isA,the end of the table is (b) and notB.In addition:ls=(a)the table header isa, the end of the table is an empty table(). 
(2non-null generalized table, except the table header, the rest of the elements constitute a table called the footer, so the non-empty generalized footer must be a table

2,which statement declares a variable a which is suitable for referring to an array of the string objects?

(A)Char a[][];

(B) String a[];

(C) String[]a;

(D) Object a[50];

(E) String a[50];

(F) Object a[];

Resolution: BCF. In Java , when declaring an array, you cannot directly qualify the array length, only when you create the instantiated object, the given array length, so BCF pairs,DE wrong. However, A two-dimensional array cannot be declared like A , and A low-dimensional length needs to be specified.

3, system, function void Func (char str[100]) {} sizeof (str) =

Parsing: Array names do formal parameters, subscript does not work, incoming is the address, usually can be written as pointer char* str, the size of the pointer in the system is 4 bytes. If it is a bit, it is 8 bytes.

4 100*90 non- 0 10 , set the 2 , The required number of bytes is Span style= "Font-family:verdana;" >()

Parsing: Each element is represented by a line number , a column number , an element value , a sparse matrix represented by a ternary group , and three members to remember , the number of rows in the matrix , the total number of elements , so the required number of bytes is 10* (1+1+1)*2+3*2=66

5, the following array definition and assignment, the error is

(A) int intarray[];

(B) int *array=new int[3]; Intarray[1]=1; intarray[2]=2;

(C) int a[]={1, 2, 3, 4, 5};

(D) int a[] []=new int[2] []; A[0]=new Int[3]; A[1]=new Int[3];

Parse:a wrong, this way definition is not possible, declaration can, or as a formal parameter can be;

6, which statement is true for the class java.util.ArrayList?

(A) The elements in the collection is ordered.

(B) The collection is guaranteed to be immutable.

(C) The elements in the collection is guaranteed to is unique.

(D) The elements in the collection is accessed using a unique key.

(E) The elements in the collections is guaranteed to be synchronized.

Parsing:ArrayList is a dynamic array, which, in MSDN parlance, is a complex version of array that provides some of the following benefits:

1> Dynamic increase and decrease of elements;

2> implements the ICollection and IList interfaces;

3> Flexibility to set the size of an array

The Synchronized property indicates whether the current ArrayList instance supports thread synchronization, and arraylist.synchronized The static method returns the wrapper for a ArrayList thread synchronization.

If you use an instance of non-thread synchronization, you need to manually call lock to keep the thread in sync when you are accessing it in multiple threads;

Report:Vectorrepresents a contiguous area of memory, where random access is highly efficient because the displacement at the beginning of each access is fixed, but inserting the delete element in a random position is inefficient because it needs to copy the subsequent elements again. Listrepresents a non-contiguous area of memory and is linked in a two-way direction through a pair of pointers to the first and the end elements, allowing traversal in forward and backward two directions. In theListthe efficiency of inserting and deleting elements anywhere is high: The pointer must be re-assigned, but it does not need to be moved with a copy element. He does not support random access and needs to traverse intermediate elements. Each element has an additional space overhead of two pointers. deque(double-ended queue, pronounced as' Deck ') also represents a contiguous area of memory, but he supports efficient insertion and deletion of elements at its header. Some guidelines for choosing a sequential container type: If we need to randomly access a container,Vectorto be more thanListmuch better. If we keep storing the number of elements, thenVectoranother one thanLista good choice. If we need to insert and delete elements not just at the end of the container,Listobviously thanVectorgood. Unless we need to insert and delete elements at the firstVectorto be more thandequegood.

the implementation of C + + STL:

(1)vector Underlying data structure is an array that supports fast random access

(2)list Underlying data structure is a doubly linked list, supporting quick additions and deletions

(3)deque The underlying data structure as a central controller and multiple buffers, see the STL Source code Analysis P146in detail, Support for both end-to-end (middle cannot) quick additions and deletions, also support random access

(4)stack bottom is generally used (2) (3) to achieve, close the head can, without vector The reason for this is that there is a limit to capacity size and time to expansion

(5) The bottom of thequeue is generally used (2) (3) to achieve, close the head can not use vector The reason for this is that there is a limit to capacity size and time to expansion

(6) (4) and (5) is the adapter , not the container, because it is a re-encapsulation of the container

(7) the underlying data structure of the priority_queue is generally vector as the underlying container, heap heap for processing rules to manage the underlying container implementation

(8)set underlying data structure for red and black trees, ordered, not duplicated

(9)multiset Bottom data structure is red black tree, orderly, repeatable

(10)map Underlying data structure for red-black trees, orderly, non-repeating

(11)Multimap The underlying data structure is a red-black tree, orderly, repeatable

(12)hash_set The underlying data structure is a hash table, unordered, non-repeating

(13)Hash_multiset The underlying data structure is a hash table, unordered, repeatable

(14)hash_map The underlying data structure is a hash table, unordered, non-repeating

(15)Hash_multimap The underlying data structure is a hash table, unordered, repeatable

Data Structure Review 2

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.