12TH COMPUTER SCIENCE - SAMACHEER GURU
2. DATA ABSTRACTION
Section – A
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
2. Which of the following functions that retrieve information from the data type?
(A) Constructors
(B) Selectors
(C) recursive
(D)Nested
6. The data type whose representation is unknown are called
(A) Built in datatype
(B) Derived datatype
(C) Concrete datatype
(D) Abstract datatype
Section-B
Answer the following questions (2 Mark)
1. What is abstract data type?
Abstract Data type (ADT) is a type or class for objects whose behavior is defined by a set of value and a set of operations.
2. Differentiate constructors and selectors.
CONSTRUCTOR:
- Constructors are functions that build the abstract data type.
- Constructorscreate an object, bundling together different pieces of information
SELECTORS
Selectors are functions that retrieve information from the data type.
Selectors extract individual pieces of information from the object.
Section-C
Answer the following questions (3 Mark)
3. Identify Which of the following are constructors and selectors?
(a) N1=number() -- Constructor
(b) accetnum(n1) -- Selector
(c) displaynum(n1) -- Selector
(d) eval(a/b) -- Selector
(e) x,y= makeslope (m), makeslope(n) -- Constructor
(f) display() -- Selector
Section - D
Answer the following questions: (5 Mark)
1. How will you facilitate data abstraction. Explain it with suitable example.
Data abstraction is supported by defining an abstract data type (ADT), which is a collection of constructors and selectors. To facilitate data abstraction, you will need to create two types of functions:
- Constructors
- Selectors
a) Constructor:
- Constructors are functions that build the abstract data type.
- Constructors create an object, bundling together different pieces of information.
- For example, say you have an abstract data type called city.
- This city object will hold the city‟s name, and its latitude and longitude.
- To create a city object, you‟d use a function like city = makecity (name, lat, lon).
- Here makecity (name, lat, lon) is the constructor which creates the object city.
b) Selectors:
- Selectors are functions that retrieve information from the data type.
- Selectors extract individual pieces of information from the object.
- To extract the information of a city object, you would use functions like
- getname(city)
- getlat(city)
- getlon(city)
These are the selectors because these functions extract the information of the city object.
No comments:
Post a Comment