Lineala Listes: Chapitre 2

Choose a study mode

Play Quiz
Study Flashcards
Spaced Repetition
Chat to Lesson

Podcast

Play an AI-generated podcast conversation about this lesson
Download our mobile app to listen on the go
Get App

Questions and Answers

Qua esas la fundamentala karakterizivo di lineara tabelo?

  • Infiniteso di elementi kun diferanta tipi di datumi.
  • Finiteso di elementi kun identika tipi di datumi. (correct)
  • Finiteso di elementi kun diferanta tipi di datumi.
  • Infiniteso di elementi kun identika tipi di datumi.

Se lineara tabelo esas vakua, qua esas la valoro di 'n', ube 'n' reprezentas la longeso dil tabelo?

  • n = 1
  • n = 0 (correct)
  • n > 0
  • n = -1

Qua esas la rolo di ADT Lineara Tabelo?

  • Ignoras la bezoni di bazala operaci.
  • Restriktas l'uzo di certa operaci sur la tabelo.
  • Definas datumi-strukturo per lua logikala strukturo e operaci. (correct)
  • Definas datumi-strukturo nur per sua implemento.

Qua esas la maxim grava konsidero kande elektas inter diversa konservado-strukturi por lineara tabelo?

<p>La eficienteso di exekutar bazala operaci. (A)</p>
Signup and view all the answers

Qua esas la funcino InitList(&L)?

<p>Iniciadas vakua lineara tabelo. (D)</p>
Signup and view all the answers

Qua rezulto produktesas da operaco DestroyList(&L)?

<p>Distruktas la lineara tabelo e liberigas lokaco di memoro. (D)</p>
Signup and view all the answers

Qua esas la reveno-valoro di la funciono ListEmpty(L)?

<p>Booleana valoro Indikanta se la tabelo esas vakua. (D)</p>
Signup and view all the answers

Qua esas la reveno-valoro di ListLength(L)?

<p>La nombro di elementi enline la lineara tabelo. (C)</p>
Signup and view all the answers

Qua esas la skopo di operaco DispList(L)?

<p>Afishar la elementi di la tabelo. (D)</p>
Signup and view all the answers

Qua esas la funcino di GetElem(L, i, &e)?

<p>Trovar l'elemento a poziciono 'i'. (C)</p>
Signup and view all the answers

Qua esas la reveno-valoro del operaco LocateElem(L, e)?

<p>L'indexo dil unesma elemento qua match'as <code>e</code>, o 0 se nula esas trovata. (C)</p>
Signup and view all the answers

Qua esas la rezulto di aplikar ListInsert(&L, i, e)?

<p>Inseras nova elemento <code>e</code> avan poziciono <code>i</code>. (B)</p>
Signup and view all the answers

Qua esas l'efekto di ListDelete(&L, i, &e)?

<p>Removar l'elemento a poziciono 'i' e returnar ol en<code>e</code>. (A)</p>
Signup and view all the answers

Kom organizesas elementi en lineara tabelo uzante sequencala konservado?

<p>Elementi esas adjacante en memoro segun logikala ordeno. (C)</p>
Signup and view all the answers

Qua esas la sinifikado di "logikal ordino" relate sequencala konservado?

<p>L'ordino ube on intencas la elementi esar acesebla. (C)</p>
Signup and view all the answers

Qua esas la funcino di 'length'-membro en la tipo-defino di lineara tabelo?

<p>Konservar la reala quanto de elementi en la tabelo. (C)</p>
Signup and view all the answers

En la dato-strukturo di sequencala tabelo, qua indikas la frazo: "Atenco: logikal sinso e fizikal sinso esas diferanta per 1"?

<p>L'indexo en programala kodo komencas de 0, kontre ke sinso de homo komencas de 1. (C)</p>
Signup and view all the answers

Kande on kreas tabelo, qua skopo servas SqList *&L en CreateList(SqList *&L, ElemType a[], int n)?

<p>Ol provizas adreso dil pointero por ke la tabelo povas modifikar. (D)</p>
Signup and view all the answers

Qua esas la funcino di lineo di kodo L=(SqList *)malloc(sizeof(SqList)) kande on kreas tabelo?

<p>Ol atribuas la memoro a <code>L</code> por la tabelo ensequo (A)</p>
Signup and view all the answers

En la funciono InitList(SqList *&L), qua efekto havas la atribuajo L->length=0?

<p>Ol deklaras la tabelo kom vakua fixigante sua longeso ad esar 0. (D)</p>
Signup and view all the answers

Qua esas l'efekto di free(L) en la funciono DestroyList(SqList *&L)?

<p>Ol delasignas la memoro asigatita a la tabelo. (C)</p>
Signup and view all the answers

En tabelo, qua indikas la kodo return(L->length==0) en ListEmpty(SqList *L)?

<p>Ol checkas e retornas 'true' se la tabelo esas vakua, 'false' alterskope. (C)</p>
Signup and view all the answers

En la funciono TabelloLongeso, qua indikas la kodo return(L->longeso)

<p>Ol retounas la membro <code>longeso</code> indikas la quanto de elementos en la tabelo. (C)</p>
Signup and view all the answers

Qua esas la primordialo prekayuzo ante imprimadar la kontenajo di lineara tabelo kun DispList(SqList *L)?

<p>Checkar se la tabelo esas vakua. (A)</p>
Signup and view all the answers

Qua esas la signifikado dil algoritmo-komplexeso O(1) por GetElement(L, i, &e) en tabelo sinuso?

<p>La tempo bezonita esas konstanta, senkonsidere la grandeso dil tabelo. (D)</p>
Signup and view all the answers

Plurafoye dum LocateElement(L, ElemType e)‎, qua esas la implico se la algoritmo atingas return 0?

<p>La elemento ne esas en la tabelo. (A)</p>
Signup and view all the answers

Qua esas la konsekuenco dil manko di checkaji por korekto di parametro en ListInsert?

<p>La programo modifikus memoro-loko exter limito e domajaras datumi. (A)</p>
Signup and view all the answers

Dum operaco ListInsert‎, por qua motivo esas necese movar elementi ante inserir novan?

<p>Por facar loko por la novan elermento sen superskribita la existantan. (A)</p>
Signup and view all the answers

Quale esas la nombro de movi en ListInsert‎, kande la insertajo avenas a la maxim lasta loko?

<p>Esas neceso movar elementi. (B)</p>
Signup and view all the answers

Qua esas la algoritm-komplexeso en optimala okazioni en la operaco ListInsert?

<p>O(1) (D)</p>
Signup and view all the answers

Proque la delezeto en sinuso esas O(n) por mezavalora tempo?

<p>Omnaloke es movebla elementumo pos l'eliminito. (C)</p>
Signup and view all the answers

Dum algoritmo desegno pro lineala tabelo per speciala prioritet por eficeco, qua esas rekomendes por konvertar?

<p>Mova frequento de operato. (C)</p>
Signup and view all the answers

Quala estas la komplikeco de tempo se la operaco de movado devas esti unufoje en la sinuso-tablo?

<p>O(n) (A)</p>
Signup and view all the answers

Preimagine se vi havas lernanto datumo konservata tra sinuso-tablo‎‎, qual qual esas la maxim raciona approĉo pro subtenar kaj la organizon kaj la eficeco?

<p>Uzo ordigita sinuso-tablo. (D)</p>
Signup and view all the answers

Qual esas utiligata la rekonstruko pro senigas datumo kun partikulara valoro ' x ' de sinusa tablo ' A ' ?

<p>Konstrutas nova tablo ‎,el eniga elekta datumo ekekzistas en A por seniga valoro x . (B)</p>
Signup and view all the answers

Qual esas mova metodo per seniganta 'x'‎ valorojn desde tablon, quante estas influitita per la komencuma nombroj des ‎'x's trovitaja?

<p>Nombro des paŝoj pli grandigus se nomblante des ‎'x'‎ plus altiğus. (A)</p>
Signup and view all the answers

En metodo per partisionar kaj ordigas sinuson-tablon 'L' kun rigardante al pioniro, qual esas la celo?

<p>Grupas elementes kiel plus larĝa kun plus petita de pioniere. (D)</p>
Signup and view all the answers

Qual es la plus grande diferenteco inter soluciono kun mova metodo kaj kun interŝanĝiga metodo pro reordinigo sinuso tablon?

<p>Interŝanĝiga metodo implicon de alie movanta punkton al la fino des procezizo al. (D)</p>
Signup and view all the answers

Kio est as pro gajnanta datuma maniero post faro sinuso tablo laboro-surloke ?

<p>Ŝanĝajo al plie bona algoritmo. (A)</p>
Signup and view all the answers

Flashcards

Quale definas lineara tabelo?

Lineara tabelo esas finita sequo de datal elementi kun sama traito.

Quo esas la longeso di lineara tabelo?

La nombro de elementi en lineara tabelo.

Quo esas InitList(&L)?

Konstruktir vakua lineara tabelo.

Quo esas DestroyList(&L)?

Liberigar la memoro uzata da lineara tabelo.

Signup and view all the flashcards

Quo esas ListEmpty(L)?

Kontrolar se lineara tabelo esas vakua.

Signup and view all the flashcards

Quo esas ListLength(L)?

Retornar la nombro de elementi en lineara tabelo.

Signup and view all the flashcards

Quo esas DispList(L)?

Montrar la valori en lineara tabelo sequencale.

Signup and view all the flashcards

Quo esas GetElem(L, i, &e)?

Retornar l'elementu che specifikita loko(i) en lineara tabelo.

Signup and view all the flashcards

Quo esas LocateElem(L, e)?

Trovir l'unesma loko ube la valore esas egala a 'e' en lineara tabelo.

Signup and view all the flashcards

Quo esas ListInsert(&L, i, e)?

Inserez nova elementu 'e' ante l' elementu che poziciono 'i' en lineara tabelo.

Signup and view all the flashcards

Quo esas ListDelete(&L, i, &e)?

Efacar l' elementu che poziciono 'i' de lineara tabelo.

Signup and view all the flashcards

Quo esas lineara tabelo ADT?

Linear tabelo ADT kombinas logikala strukturo ed operaci.

Signup and view all the flashcards

Quo esas sequencala konservado?

Lineara tabelo en memoro.

Signup and view all the flashcards

Quale laboresas sequencala konservado?

Organizala dato en kontinua chunk di memoro.

Signup and view all the flashcards

Quo esas typedef struct?

Definar sequencala tabelo tipo uzanta Struct.

Signup and view all the flashcards

Quo esas CreateList(SqList *&L, ElemType a[], int n)?

Krear sequencala tabelo.

Signup and view all the flashcards

Quo esas libera (L)?

Liberigar la loko en memoro.

Signup and view all the flashcards

Quo esas LocateElem (SqList *L, ElemType e)?

Retornar 0 se ne trovesas.

Signup and view all the flashcards

Quo esas bool ListInsert (SqList *&L, int i, ElemType e)?

Inserar elemento en tabelo.

Signup and view all the flashcards

Quo esas bool ListDelete(SqList *&L, int i, ElemType &e)?

Eliminar elemento de tabelo.

Signup and view all the flashcards

Quale esas bona algoritmo?

Algoritmo kun O (1) esas maxim bona.

Signup and view all the flashcards

Quale esas lenta algoritmo?

Algoritmo kun O (n) esas maxim mala.

Signup and view all the flashcards

Quo esas move1?

Adaptar datumi en strukturo.

Signup and view all the flashcards

Quo esas move2?

Bona datumo adapteso.

Signup and view all the flashcards

Study Notes

  • Chapter 2 studies linear lists

2.1 Basic Concepts of Linear Lists

  • A linear list is a limited sequence of data elements with the same characteristics.
  • The same characteristics: all elements belong to the same data type.
  • Limited: the number of data elements is limited.
  • Sequence: data elements are uniquely determined by the logical sequence number. A linear list can have elements with the same value.
  • The number of elements contained in a linear list is length, indicated by n, where n≥0.
  • When n=0, the linear list is an empty list, that is, the table does not contain any elements.
  • The logical representation is (a1, a2,..., ai, ai+1,..., an).
  • ai (1≤i≤n) shows the i-th (i indicates the logical position) element

2.1.2 Linear List Operations

  • InitList(&L): Constructs an empty linear list L.
  • DestroyList(&L): Frees the memory space occupied by the linear list L.
  • ListEmpty(L): Returns true if L is an empty list, false otherwise.
  • ListLength(L): Returns the number of elements n in L.
  • DispList(L): Sequentially displays the domain of values of each node in L when the linear list L is not empty.
  • GetElem(L, i, &e): Returns the value of the i-th (1≤i≤n) element in L using e.
  • LocateElem(L, e): Returns the logical position of the first value domain equal to e in L; if such an element does not exist, returns 0.
  • ListInsert(&L, i, e): Inserts a new element e before the i-th (1≤i≤n) element in L; the length of L is increased by 1.
  • ListDelete(&L, i, &e): Deletes the i-th (1≤i≤n) element in L and returns its value with e; the length of L is decreased by 1.
  • Programmers can directly use it to store data as a container for storing data.
  • Programmers can directly use its basic operations to accomplish more complex functions.
  • ADT for linear lists includes linear list ADT = logical structure + basic operations (operation description)

2.2 Sequential Storage Structure of Linear Lists

  • Store all elements in the linear list with a sequential storage method, storing sequentially in a contiguous storage space in memory. Data member stores elements, length stores the sequence's actual length.
  • Logical and physical positions differ by 1.

2.2.2 Implementation of Sequence List Operations

  • To create a sequence list, a[0..n-1] creates a sequence list L as a whole

  • Function prototype is void CreateList(SqList *&L, ElemType a[], int n)

  • Sequence list pointed is passed by pointer.

  • To initialize a sequence list, this operation constructs an empty sequence list L with the member length set to 0.

  • To destroy a sequence list, this operation frees the memory space occupied by the linear list L via function void DestroyList(SqList *&L)

  • To determine if a list is empty, this operation returns returns true if L is an empty sequence list, false if it is not via the function bool ListEmpty(SqList *L)

  • To retrieves the length of a linear list via function int ListLength(SqList *L), this operation returns the length of the sequence list L, it simply returns the length member's value.

  • To output a linear list, via the function void DispList(SqList *L), this operation displays the value of each element in L when the sequence list L is not empty.

  • Retrieves the value of a data element at a certain point, via the function bool GetElem(SqList *L, int i, ElemType &e), this operation returns the value of the i-th (1≤i≤ListLength(L)) element in L and stores it in e.

  • With O(1) complexity, it embodies the random access feature.

  • When locating an element's value using int LocateElem(SqList *L, ElemType e), it searches through via the sequential order, starting from the 1st value, the logical order of the element that equals e; Returns value is 0.

  • To insert data, using bool ListInsert(SqList *&L, int i, ElemType e) the operation inserts the element, e.

  • The time complexity of moving existing elements is relevant to the list L->length and insert position 'i'

  • When i = n+1, the number of moves = 0

  • When i = 1, the number of moves = n (max value)

  • Best time complexity is O(1)

  • The worst algorithms time complexity is O(n)

  • When deletion is performed using bool ListDelete(SqList *&L , int i, ElemType &e), this operation deletes the i-th (1 ≤ i ≤ ListLength(L)) element of the sequential list L.

  • When i = n, the number of moves is 0

  • When i=1, the number of moves will be n-1.

  • The best time complexity for the deletion algotithm = 0(1)

  • The worst time complexity = 0(n)

  • When performing list algorithm design, take note that the data should be stored with sequence list storage and use the fundamental sequence table to complete tasks.

Example Algorithms

  • Given a list of length n, design an algorithm with time complexity of 'O(n) and space complexity of 'O(1) to remove all elements in the list of value, 'x'.

  • A solution requires moving all elements, resulting in 'O(n*n) time complexity with space complexity unaffected!

  • Alternatively moving all non-'x' valued elements creates 'O(n)' Space & time complexity!

  • Solution Remove all values equal to "x", with k tracking elements.

    • Implementation is akin to re-establishing the sequence!
  • A secondary solution using k tracks a number of elements equal to x during the A-scan and statistic collection, and uses this shift non x terms.

  • Given list with 10 intergers, take the 1st as the median, with all smaller or equal to, to the left, and the greater elements to it's right

  • pivot = 'L' -> data[0] uses 0 - 9 scan for less than values & greater values while exchanging elements!

    • Function is void move1(SqList *&L)
  • Alternatively pivots can be moved to front or behind pivot = 'L' -> data[0] via Function 'void move2(SqList '&L')' and while the algorithm scales in 'O(n)', the first method is preferred due to fewer record moves overall!

Studying That Suits You

Use AI to generate personalized quizzes and flashcards to suit your learning preferences.

Quiz Team

Related Documents

线性表: Data Structures PDF

More Like This

Data Structures Quiz
10 questions

Data Structures Quiz

InsightfulTourmaline avatar
InsightfulTourmaline
Linear List Data Structure Quiz
5 questions
Basic Data Structures Quiz
24 questions

Basic Data Structures Quiz

SolidExpressionism avatar
SolidExpressionism
Linear Data Structures
37 questions

Linear Data Structures

FashionableHappiness avatar
FashionableHappiness
Use Quizgecko on...
Browser
Browser