Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- case 2:
- begin = clock();
- plik.open("rand.txt");
- int g = 1;
- for (int i = 0; i < numberOfNodes; i++)
- {
- if ((numberOfInserted % 2) == 1)
- {
- plik >> tab[i];
- insert(tab[i]);
- }
- else
- {
- insert(g);
- g++;
- }
- }
- plik.close();
- end = clock();
- time_spent = (double)(end - begin) * CLOCKS_PER_SEC / 1000;
- printf("Wstawiono %d elementow", numberOfInserted);
- printf("\n%f ", time_spent);
- ///////////////////////////////////////////////////////////////
- begin = clock();
- plik.open("rand.txt");
- for (int j = 0; j < numberOfNodes; j++)
- {
- plik >> tab[j];
- findKey(tab[j]);
- }
- plik.close();
- end = clock();
- time_spent = (double)(end - begin) * CLOCKS_PER_SEC / 1000;
- printf("\nOdszukano %d elementow", numberOfInserted);
- printf("\n%f ", time_spent);
- ///////////////////////////////////////////////////////////////
- begin = clock();
- numberOfFound = 0;
- for (int j = 0; j < numberOfNodes; j++)
- {
- int val = (rand() << 9) % 10000000;
- findKey(val);
- }
- end = clock();
- time_spent = (double)(end - begin) / CLOCKS_PER_SEC / 1000;
- printf("\nOdszukano %d elementow", numberOfFound);
- printf("\n%f ", time_spent);
- //////////////////////////////////////////////////////////////////////
- begin = clock();
- for (int k = 0; k < numberOfNodes; k++)
- {
- int key = (rand() << 9) % 10000000;
- remove(key);
- }
- end = clock();
- time_spent = (double)(end - begin) * CLOCKS_PER_SEC / 1000;
- printf("\n Usunieto %d elementow", numberOfRemoved);
- printf("\n%f ", time_spent);
- //////////////////////////////////////////////////////////////////////
- begin = clock();
- plik.open("rand.txt");
- numberOfRemoved = 0;
- for (int l = 0; l < numberOfNodes / 2; l++)
- {
- plik >> tab[l];
- remove(tab[l]);
- }
- plik.close();
- end = clock();
- time_spent = (double)(end - begin) * CLOCKS_PER_SEC / 1000;
- printf("\n Usunieto %d elementow", numberOfRemoved);
- printf("\n%f ", time_spent);
- break;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement