Geschreven door studenten die geslaagd zijn Direct beschikbaar na je betaling Online lezen of als PDF Verkeerd document? Gratis ruilen 4,6 TrustPilot
logo-home
College aantekeningen

Fundamentals of Big O Notation, what is void pointer

Beoordeling
-
Verkocht
-
Pagina's
6
Geüpload op
11-04-2025
Geschreven in
2024/2025

The fundamental idea We use Big O notation which describes the upper bound the worst-case scenario of how the runtime increases. Introduction to Void Pointers Void pointers, also known as generic pointers, are a powerful tool in C programming. They allow us to create a pointer that can point to any data type, making them incredibly versatile. However, because of their versatility, they can also be dangerous if not used correctly.

Meer zien Lees minder
Instelling
Vak

Voorbeeld van de inhoud

1


The fundamental idea We use Big O notation which describes

the upper bound the worst-case scenario of how the runtime

increases.


Guideline 1: Single Loops



●​ Think about a simple for loop running from 1 to n. Inside that loop, you have

a statement.

●​ How many times does that statement run The answer is n times once for

each iteration of the loop.

●​ If that statement takes a constant amount of time to execute were ignoring

loop conditions and initializations for now, then the total time complexity is

On.



Lets put it in code:



python def processitemsn: for i in range1, n + 1: # Some constant-time operation

here printfProcessing item i

, 2




As n doubles, the number of times the loop runs and the time taken roughly

doubles. This is linear growth.



Guideline 2: Nested Loops - The Power of Multiplication



●​ This is where things get a little trickier. What happens when you have a loop

within another loop This is called a nested loop.

●​ Lets say you have an outer loop that runs n times, and an inner loop that also

runs n times for each iteration of the outer loop.

●​ Imagine this visually: for each i in the outer loop 1, 2, 3...n, the inner loop

does a full cycle 1, 2, 3...n.

●​ So, the statement inside the inner loop executes n * n = n times. Thats a

significant jump from just n We express this as On. This is quadratic growth.



Heres a code example to illustrate:



python def processpairsn: for i in range1, n + 1: for j in range1, n + 1: # Some

constant-time operation here printfProcessing pair i, j

Geschreven voor

Instelling
Vak

Documentinformatie

Geüpload op
11 april 2025
Aantal pagina's
6
Geschreven in
2024/2025
Type
College aantekeningen
Docent(en)
Mr adam judith
Bevat
Alle colleges

Onderwerpen

$8.49
Krijg toegang tot het volledige document:

Verkeerd document? Gratis ruilen Binnen 14 dagen na aankoop en voor het downloaden kun je een ander document kiezen. Je kunt het bedrag gewoon opnieuw besteden.
Geschreven door studenten die geslaagd zijn
Direct beschikbaar na je betaling
Online lezen of als PDF

Maak kennis met de verkoper
Seller avatar
saaishrribk

Maak kennis met de verkoper

Seller avatar
saaishrribk JHSS (CBSE),Neyveli
Volgen Je moet ingelogd zijn om studenten of vakken te kunnen volgen
Verkocht
-
Lid sinds
1 jaar
Aantal volgers
0
Documenten
4
Laatst verkocht
-

0.0

0 beoordelingen

5
0
4
0
3
0
2
0
1
0

Recent door jou bekeken

Waarom studenten kiezen voor Stuvia

Gemaakt door medestudenten, geverifieerd door reviews

Kwaliteit die je kunt vertrouwen: geschreven door studenten die slaagden en beoordeeld door anderen die dit document gebruikten.

Niet tevreden? Kies een ander document

Geen zorgen! Je kunt voor hetzelfde geld direct een ander document kiezen dat beter past bij wat je zoekt.

Betaal zoals je wilt, start meteen met leren

Geen abonnement, geen verplichtingen. Betaal zoals je gewend bent via iDeal of creditcard en download je PDF-document meteen.

Student with book image

“Gekocht, gedownload en geslaagd. Zo makkelijk kan het dus zijn.”

Alisha Student

Bezig met je bronvermelding?

Maak nauwkeurige citaten in APA, MLA en Harvard met onze gratis bronnengenerator.

Bezig met je bronvermelding?

Veelgestelde vragen