Portal | IBM Manuals | Downloads | Products | Refer | Info | Programs | JCLs | Forum Rules*| Site Map | Mainframe CD 
IBMMAINFRAMES.com - IBM Mainframe Support Forums Index
 
Register
 
IBMMAINFRAMES.com - IBM Mainframe Support Forums Index FAQ Search Memberlist Usergroups Profile Log in to check your private messages Log in
 
cts interview question

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> Interview Questions
Author Message
cooolguyin
Warnings : 1

New User


Joined: 12 May 2005
Posts: 13
Location: chennai

PostPosted: Thu Jun 09, 2005 12:14 am    Post subject: cts interview question
Reply with quote

here is the interview Q i faced in cts

There are two files one with the records in sorted order , no duplicates and other with unsorted order with duplicates..I want the third file which should contain the records that are in both the first and second file but no duplicates.. should not use merge or sort verb!!.

could you just tell me the logic of this pgm?

Thanks in advance
Back to top
View user's profile Send private message
References
cooolguyin
Warnings : 1

New User


Joined: 12 May 2005
Posts: 13
Location: chennai

PostPosted: Thu Jun 09, 2005 12:16 am    Post subject:
Reply with quote

and the output file should be in the sorted order!
Back to top
View user's profile Send private message
naive

New User


Joined: 26 Apr 2005
Posts: 47
Location: LA

PostPosted: Thu Jun 09, 2005 3:22 am    Post subject:
Reply with quote

Algo:
1.Read 1st file
2.If not EOF , goto next line ELSE goto line 8.
3. Read 2nd file
3.If 2nd file not EOF, goto next line, ELSE goto 6.
4.If 1st file rec = 2nd file rec, goto next line,ELSE goto line 3.
5.Write record to 3rd file.
6.Close 2nd file,open 2nd file (reset file pointer to 1st record in file 2)
7.Goto 1.
8.END


Assumption:1st file is the sorted one,without duplicates. 2nd file has duplicates and is unsorted.

Lemme know if this is OK.
Back to top
View user's profile Send private message
Santoshhn

New User


Joined: 18 May 2005
Posts: 6

PostPosted: Thu Jun 09, 2005 12:39 pm    Post subject:
Reply with quote

Code this logic..this has to work..


if key-1 < key-2 and
key-1 not= hold-key-1
move key-1 to hold-key-1
write record-1
read file-1
else if key-1 > key-2 and
key-2 not= hold-key-2
write record-2
move key-2 to hold-key-2
read file-2
else if key-1 = key-2 and
key-1 not= hold-key-1
write either record-1 or record-2
read file-1
read file-2
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> Interview Questions All times are GMT + 6 Hours
Page 1 of 1