Pagination
is the process of dividing content into discrete pages. Pagination is common in
Web-based applications, and is used for limiting the result set and displaying
a limited number of records on the web page.
For example, consider the Department-Employee scenario. If the search operation
is performed on the basis of Department Id, and there are 100,000 employees per
department, then it does not make sense to display the details of 100,000
employees in single page. So, pagination allows to display limited results e.g.
20 records per page. "Previous" and "Next" links or the
Page numbers are usually provided on the user interface so that users can
navigate to other pages.
Your task is to write a program for selecting the records that need to be
displayed on user interface. Records should be filtered as per the input
parameters, and should be sort-able by any field.Sort in asecending order.
Your program should extract the records from a file on the basis of input
parameters. For example, if the input is (Department ID-10, Page Size-20, and
Page Number -1), then the program should retrieve first set of 20 records for
Department ID-10 sort-able by any field. If the input is (Department ID-10,
Page Size-20, and Page Number -2), then the program should retrieve second set
of 20 records.
Information:
·
Expected
Volumes: Department Data File may have approx. 100,000 records per department
ID. Page Size is expected to be less than 100 records.
·
Application
also allows other search operations on the basis of Employee ID, Name
,Grade.Program should be able to sort on any of these fields
Input Format:
|
Line 1 |
|
|
Line 2 |
·
Column(C) on which sort need to be happen ·
Department ID (D) is search Parameter ·
Page Size (S) is number of records that need to be
displayed on UI e.g. 20 ·
Page Number(N) is the number of Page which should be
displayed e.g. 2 (2nd Page to be displayed) |
File Format
Number of Columns-4
Order of Column -DEPT_ID,EMP_ID ,EMP_NAME,GRADE
Columns delimited by comma(,)
Example Department Data
File:
DEPT_ID,EMP_ID,EMP_NAME,GRADE
1,1,Smith Frank,A
1,2,Manager Mike,C
1,3,Driver Danny,D
2,7,Bliss,B
2,8,Java,D
2,9,Kyte Kelly,B
1,4,Boat Tony,A
2,5,Louie Chef,B
2,6,Lawson,C
2,10,Baker Sarah,D
2,11,Smothers Sally,A
2,12,Silly Sall,C
2,13,Viper,B
2,14,Beck,B
2,15,Rambo,A
Note:
This is a sample data file only. Actual data file may contain more / less data,
but is guaranteed to adhere to this format.
Output:
Output of the program will be the filtered records that need to be displayed on
UI (User Interface). Records should be sorted by Employee Names and should be
filtered as per the input parameters.
Sample Input and Output
|
SNo. |
Input |
Output |
Remark |
|
1 |
|
|
Second Page with 3 records from ordered data of Dept ID-2. Ordered by Emp
ID |
|
2 |
|
|
-- |
|
3 |
|
|
-- |
|
4 |
|
|
Based on sample data above, DEPT_ID 9 does not exist. Hence data will be
unavailable for this input. |
|
5 |
|
|
First Page with 2 records from ordered data of Dept ID-1. Ordered by
GRADE |


0 Comments