Overclock.net › Forums › Software, Programming and Coding › Coding and Programming › Quick question about general information on loops.
New Posts  All Forums:Forum Nav:

Quick question about general information on loops.

post #1 of 2
Thread Starter 
The question I have is which of these items describe a sentinel controlled loop:

Deterministic loop
Pretest loop
Nondeterministic loop
Midtest loop
Posttest loop

And the second question with the same list is which describes a data-validation loop.

I am thinking:

Sentinel controlled loop = Nondeterministic loop.
While data-validation loop= Pretest, Midtest, posttest.
correct me if I am wrong, but I just wanted to make sure.

Thanks in advance,
Bob
Edited by Bobicon - 2/3/12 at 7:37pm
Bob's Computer
(16 items)
 
  
CPUMotherboardGraphicsRAM
Intel i5 2500K MSI P67A-G45 MSI 6970 Lightning 2GB G Skill Ripjaws X (2x4GB) 1866mhz 9-10-9-28 
Hard DriveOptical DriveCoolingOS
Corsair Force 3 SSD (60GB), X1 WD5000AAKS, X1 W... ASUS DRW-24B1ST/BLK/B/AS Black SATA 24X DVD Burner Noctua NH-C14 Windows 7 64 bit 
MonitorKeyboardPowerCase
Asus VH238H Logitech G510 HALE90 750W NZXT Phantom Black 
MouseMouse PadAudioOther
Logitech G9x SteelSeries 4HD ASUS Xonar DGX / Audio-Technica ATH-AD700 Hauppauge! HVR-1250 TV Tuner 
  hide details  
Reply
Bob's Computer
(16 items)
 
  
CPUMotherboardGraphicsRAM
Intel i5 2500K MSI P67A-G45 MSI 6970 Lightning 2GB G Skill Ripjaws X (2x4GB) 1866mhz 9-10-9-28 
Hard DriveOptical DriveCoolingOS
Corsair Force 3 SSD (60GB), X1 WD5000AAKS, X1 W... ASUS DRW-24B1ST/BLK/B/AS Black SATA 24X DVD Burner Noctua NH-C14 Windows 7 64 bit 
MonitorKeyboardPowerCase
Asus VH238H Logitech G510 HALE90 750W NZXT Phantom Black 
MouseMouse PadAudioOther
Logitech G9x SteelSeries 4HD ASUS Xonar DGX / Audio-Technica ATH-AD700 Hauppauge! HVR-1250 TV Tuner 
  hide details  
Reply
post #2 of 2
Quote:
Originally Posted by Bobicon View Post

The question I have is which of these items describe a sentinel controlled loop:
Deterministic loop
Pretest loop
Nondeterministic loop
Midtest loop
Posttest loop
And the second question with the same list is which describes a data-validation loop.
I am thinking:
Sentinel controlled loop = Nondeterministic loop.
While data-validation loop= Pretest, Midtest, posttest.
correct me if I am wrong, but I just wanted to make sure.
Thanks in advance,
Bob

I would say you're right on the first question. Since the number of iterations of a non-deterministic loop is not known in advance, it makes sense to control the loop by using a sentinel value. This, of course, eliminates the 'deterministic loop' answer from both questions.

Data validation loops generally require the data to be read at least once, then tests for the data's validity. In this case, if I had to choose one, I would go for post-test loop, as the testing would be done post-loop. To me it would not make sense to test the data before executing the loop, as the data would need to be read during an iteration before being validated after the iteration has finished. Does this make sense?

That being said, it can also be validated during the loop (i.e. mid-test in your list of questions).

Here's an example:
Code:
do {
    cout << "Enter a month number\n";
    cin >> monthNumber;
    if (monthNum < 1 || monthNum > 12)
      cout << "Month number not in range!" << endl;
}
while (monthNum < 1 || monthNum > 12);

A mid-test and a post-test is performed (the if statement being the mid-test and the while statement being the post-test), however I don't see a viable reason for a pre-test in a loop, unless you can point one out to me. Unless there is data to be processed, I don't think it would be done in a loop.

EDIT:

Never mind. You're right. The following would be a pre-test:
Code:
while (monthNum < 1 || monthNum > 12);

Edited by jNSK - 2/3/12 at 10:37pm
Project 4
(13 items)
 
  
CPUMotherboardGraphicsRAM
i5 750 Lynnfield @ 4.4 GHz, 1.41v EVGA P55 SLi (132-LF-E655-KR) - A72 BIOS EVGA GeForce GTX 680 4GB G.Skill Ripjaws @ 9-9-9-24, 1.51V 
Hard DriveOptical DriveOSMonitor
80GB Intel X25-M SSD + 500GB WD + 2TB Samsung F3 Samsung Super Writemaster DVD+-R Windows 7 Ultimate Edition Samsung SyncMaster 2433 24" 
KeyboardPowerCaseMouse
Logitech G15 Corsair TX750 750W Corsair Obsidian 800D + Scythe Kaze Master Ace Razer Deathadder Respawn - Black 
Mouse Pad
Steelseries QcK Medium - Black 
  hide details  
Reply
Project 4
(13 items)
 
  
CPUMotherboardGraphicsRAM
i5 750 Lynnfield @ 4.4 GHz, 1.41v EVGA P55 SLi (132-LF-E655-KR) - A72 BIOS EVGA GeForce GTX 680 4GB G.Skill Ripjaws @ 9-9-9-24, 1.51V 
Hard DriveOptical DriveOSMonitor
80GB Intel X25-M SSD + 500GB WD + 2TB Samsung F3 Samsung Super Writemaster DVD+-R Windows 7 Ultimate Edition Samsung SyncMaster 2433 24" 
KeyboardPowerCaseMouse
Logitech G15 Corsair TX750 750W Corsair Obsidian 800D + Scythe Kaze Master Ace Razer Deathadder Respawn - Black 
Mouse Pad
Steelseries QcK Medium - Black 
  hide details  
Reply
New Posts  All Forums:Forum Nav:
  Return Home
  Back to Forum: Coding and Programming
Overclock.net › Forums › Software, Programming and Coding › Coding and Programming › Quick question about general information on loops.