Data Abstraction and Abstract Data Types: book back answers

19 solved questions from the end of this chapter, Class 12 Computer Science, Tamil Nadu State Board. Each answer is checked against the textbook, and you can open the page that proves it.

← Notes and quiz for Data Abstraction and Abstract Data Types

Choose the best answer (1 Mark)

  1. Which of the following functions that build the abstract data type ?

    • (A) Constructors
    • (B) Destructors
    • (C) recursive
    • (D)Nested
    Try it, then show the answer

    (A) Constructors

    Constructors build the abstract data type.

    From the book: “Constructors are functions that build the abstract data type.”

  2. Which of the following functions that retrieve information from the data type?

    • (A) Constructors
    • (B) Selectors
    • (C) recursive
    • (D)Nested
    Try it, then show the answer

    (B) Selectors

    Selectors retrieve information from a data type.

    From the book: “Selectors are functions that retrieve information from the data type.”

  3. The data structure which is a mutable ordered sequence of elements is called

    • (A) Built in
    • (B) List
    • (C) Tuple
    • (D) Derived data
    Try it, then show the answer

    (B) List

    A list can store multiple values, and its elements can be changed. The chapter contrasts this with a tuple, whose elements cannot be changed once assigned.

    From the book: “in a list, elements can be changed.”

  4. A sequence of immutable objects is called

    • (A) Built in
    • (B) List
    • (C) Tuple
    • (D) Derived data
    Try it, then show the answer

    (C) Tuple

    A tuple is a sequence of values whose elements cannot be changed once it is assigned.

    From the book: “you cannot change the elements of a tuple once it is assigned”

  5. The data type whose representation is known are called

    • (A) Built in datatype
    • (B) Derived datatype
    • (C) Concrete datatype
    • (D) Abstract datatype
    Try it, then show the answer

    (C) Concrete datatype

    A concrete data type is defined by having a known representation.

    From the book: “A concrete data type is a data type whose representation is known.”

  6. The data type whose representation is unknown are called

    • (A) Built in datatype
    • (B) Derived datatype
    • (C) Concrete datatype
    • (D) Abstract datatype
    Try it, then show the answer

    (D) Abstract datatype

    The chapter says an abstract data type's representation is unknown and its definition does not specify how data is organized in memory.

    From the book: “in abstract data type the representation of a data type is unknown”

  7. Which of the following is a compound structure?

    • (A) Pair
    • (B) Triplet
    • (C) single
    • (D) quadrat
    Try it, then show the answer

    (A) Pair

    Pair is the compound structure made up of a list or tuple.

    From the book: “Pair is a compound structure which is made up of list or Tuple”

  8. Bundling two values together into one can be considered as

    • (A) Pair
    • (B) Triplet
    • (C) single
    • (D) quadrat
    Try it, then show the answer

    (A) Pair

    Bundling two values into one is considered a pair.

    From the book: “Bundling two values together into one can be considered as a pair”

  9. Which of the following allow to name the various parts of a multi-item object?

    • (A) Tuples
    • (B) Lists
    • (C) Classes
    • (D) quadrats
    Try it, then show the answer

    (C) Classes

    The chapter uses a class to represent a multi-part object where each part is named.

    From the book: “use the structure construct (In OOP languages it's called class construct) to represent multi-part objects where each part is named”

  10. Which of the following is constructed by placing expressions within square brackets?

    • (A) Tuples
    • (B) Lists
    • (C) Classes
    • (D) quadrats
    Try it, then show the answer

    (B) Lists

    A list is formed by placing expressions in square brackets separated by commas.

    From the book: “List is constructed by placing expressions within square brackets separated by commas.”

Part - II — Answer the following questions (2 Marks)

  1. What is abstract data type?

    Try it, then show the answer

    An abstract data type (ADT) is a type for objects whose behavior is defined by a set of values and operations. It specifies what operations are performed, not how they are implemented.

    An ADT provides an implementation-independent description of an object's behavior and operations.

    From the book: “Abstract Data type (ADT) is a type for objects whose behavior is defined by a set of values and operations.”

  2. Differentiate constructors and selectors.

    Try it, then show the answer

    Constructors build an abstract data type, whereas selectors retrieve information from it.

    For example, makecity creates a city object; getname, getlat and getlon extract information from it.

    From the book: “Constructors are functions that build the abstract data type. Selectors are functions that retrieve information from the data type.”

  3. What is a List? Give an example.

    Try it, then show the answer

    A list is constructed by placing expressions within square brackets separated by commas. For example, [10, 20].

    A list can store multiple values, including values of different types or another list.

    From the book: “List is constructed by placing expressions within square brackets separated by commas.”

  4. What is a Tuple? Give an example.

    Try it, then show the answer

    A tuple is a comma-separated sequence of values surrounded by parentheses. For example, nums := (1, 2).

    Unlike a list, a tuple's elements cannot be changed once it is assigned.

    From the book: “A tuple is a comma-separated sequence of values surrounded with parentheses.”

Part - III — Answer the following questions (3 Marks)

  1. Differentiate Concrete data type and abstract datatype.

    Try it, then show the answer

    A concrete data type has a known representation. An abstract data type has an unknown or implementation-independent representation; its definition states the operations, not how they are implemented.

    A concrete representation is defined separately from the part of the program that operates on abstract data.

    From the book: “A concrete data type is a data type whose representation is known.”

  2. Which strategy is used for program designing? Define that Strategy.

    Try it, then show the answer

    The strategy is wishful thinking. It means beginning program design by assuming that the required components, such as a constructor and selectors, are available before deciding how they are represented or implemented.

    The rational-number example assumes the constructor and selectors are available without yet specifying their implementation.

    From the book: “We are using here a powerful strategy for designing programs: 'wishful thinking'.”

  3. Identify Which of the following are List, Tuple and class ? (a) arr [1, 2, 34] (b) arr (1, 2, 34) (c) student [rno, name, mark] (d) day:= (‘sun’, ‘mon’, ‘tue’, ‘wed’) (e) x:= [2, 5, 6.5, [5, 6], 8.2] (f) employee [eno, ename, esal, eaddress]

    Try it, then show the answer

    (a) List (b) Tuple (c) Class (d) Tuple (e) List (f) Class

    Square-bracketed sequences are lists, while comma-separated values in parentheses are tuples. The student and employee examples represent multi-part objects with named fields, so they are classes.

    From the book: “A tuple is a comma-separated sequence of values surrounded with parentheses.”

Part - IV — Answer the following questions (5Marks)

  1. How will you facilitate data abstraction. Explain it with suitable example

    Try it, then show the answer

    Data abstraction allows a programmer to use data by focusing on what it does, without needing to know how it is implemented. It is facilitated by using constructors to create data objects and selectors to retrieve information from them.

    1. Define the abstract data type: Specify the values and operations of the data type, without describing how the data is stored or how the operations are implemented.
    2. Use a constructor: A constructor builds an object by combining the required pieces of information.
    3. Use selectors: Selectors retrieve the individual pieces of information stored in an object.
    4. Hide implementation details: Programs can use the constructor and selectors without knowing how those functions are implemented.
    5. Keep representation independent: The same ADT can have different concrete implementations, while the operations used by a program remain abstract.
    6. Example: city data type: A city object stores its name, latitude and longitude. The makecity function constructs it, while getname, getlat and getlon select its information.

    Example: For two city objects, distance(city1, city2) uses getlat(city1), getlon(city1), getlat(city2) and getlon(city2) to calculate the distance without needing to know how the city objects are represented.

    Thus, constructors and selectors facilitate data abstraction by allowing programs to use data without depending on its concrete representation.

    From the book: “To facilitate data abstraction, you will need to create two types of functions: constructors and selectors.”

  2. How will you access the multi-item. Explain with example.

    Try it, then show the answer

    A multi-item object contains several related pieces of data. The chapter explains that its elements can be accessed using a list index or by giving each named part a field in a structure.

    1. Accessing list elements: A list stores multiple values, and an element selection operator accesses a value at a particular index.
    2. Index positions: The index is written in square brackets after the list name. The first element is accessed with index 0, and the second with index 1.
    3. Multiple assignment: A list can also be unpacked into separate variables using multiple assignment.
    4. Accessing tuple elements: A tuple’s elements are accessed with the same square-bracket notation, using their index positions.
    5. Named parts in a structure: For a complex multi-item object, a structure can name each part. This allows the parts to be identified by names rather than only by index.

    Example: For nums := (1, 2), nums[0] gives 1 and nums[1] gives 2.

    Thus, access multi-item data by index in a list or tuple, or by named fields in a structure.

    From the book: “The class (structure) construct defines the form for multi-part objects that represent a person.”

Next chapterVariable Scope and Modular Programming