빅오를 구하고 싶어요~
애기
PrintLot( List L ,List X)
이 함수의 빅오를 구하는 문제입니다.
함수가 리스트List L 과 List X가 있으면
List X의 삽입데이타 값에 요소가 1,3,4,6이라면
List L의 첫번쨰 , 세번쨰, 네번쨰, 여섯번째 위치의 요소를 출력해주는 함수입니다.
이 함수의 빅오를 구하는 문제인데
while 안에 for 문이 있으니 여기 빅오가 O(n제곱) 이렇게 되는건가요??
#include stdio.h
#include stdlib.h
struct Node
{
int Element;
struct Node *Next;
};
typedef struct Node *PtrToNode;
typedef PtrToNode List;
typedef PtrToNode Position;
int IsEmpty( List L );
int IsLast( Position P, List L );
Position Find ( int X, List L );
void Delete( int X, List L );
Position FindPrevious( int X, List L );
void Insert( int X, List L, Position P );
void DeleteList( List L );
void PrintList( List L );
void PrintLots( List L, List X );
int main(void)
{
List Header, Header2, L, X;
Header = ( List )malloc ( sizeof ( struct Node) );
Header2 = ( List )malloc ( sizeof ( struct Node) );
Header-Next = NULL;
Header2-Next = NULL;
L = Header;
X = Header2;
Insert( 7, L, L );
Insert( 10, L, Find( 7, L ) );
Insert( 28, L , Find( 10, L ) );
Insert( 5, L , Find( 10, L ) );
Insert( 4, L , Find( 10, L ) );
Insert( 3, L , Find( 10, L ) );
Insert( 9, L , Find( 10, L ) );
Insert( 20, L , Find( 10, L ) );
printf(리스트 L의 요소 : );
PrintList( L );
Insert( 1, X, X );
Insert( 3, X, Find( 1, X ) );
Insert( 4, X, Find( 3, X ) );
Insert( 6, X, Find( 4, X ) );printf(리스트 X의 요소 : );
PrintList( X );
printf(리스트 X의 요소에 위치하는 리스트 L의 요소 : );
PrintLots( L , X );
return 0;
}
int IsEmpty( List L )
{
return L-Next == NULL;
}
int IsLast( Position P, List L )
{
return P-Next == NULL;
}
Position Find(int X, List L )
{
Position P;
P = L-Next;
while( P != NULL && P-Element !=X )
P = P-Next;
return P;
}
void Delete( int X, List L)
{
Position P, TmpCell;
P = FindPrevious( X, L );
if( !IsLast( P, L) )
{
TmpCell = P-Next;
P-Next = TmpCell-Next;
free( TmpCell );
}
}
Position FindPrevious( int X, List L )
{
Position P;
P = L;
while( P-Next != NULL && P-Next-Element !=X )
P = P-Next;
return P;
}
void Insert( int X, List L, Position P )
{
Position TmpCell;
TmpCell = malloc( sizeof( struct Node ) );
if( TmpCell == NULL )
printf( Out of space !!!);
TmpCell-Element = X;
TmpCell-Next = P-Next;
P-Next = TmpCell;
}
void DeleteList( List L )
{
Position P, Temp;
P = L-Next;
L-Next = NULL;
while( P != NULL )
{
Temp = P-Next;
free( P );
P = Temp;
}
}
void PrintList( List L )
{
Position P;
P = L;
while ( P-Next )
{
printf( |%d|, P-Next-Element);
P = P-Next;
}
printf(\n);
}
void PrintLots( List L, List X )
{
Position L2, X2;
int Data=0, i;
X2 = X;
while( X2-Next )
{
Data = X2-Next-Element;
L2 = L;
//printf(Data의 값 : %d = , X2-Next-Element);
//printf(실제요소의 처음값 : %d\n, L2-Next-Element);
for(i=1; iData; i++)
{
L2 = L2-Next;
}
printf( |%d|, L2-Next-Element);
X2 = X2-Next;
}
printf(\n);
}
번호 | 제 목 | 글쓴이 | 날짜 |
---|---|---|---|
2700562 | 함수포인터에서요 (7) | 소심한여자 | 2025-07-06 |
2700530 | 전처리문 질문입니다. (1) | 아놀드 | 2025-07-05 |
2700510 | c언어를 어케하면 잘할수 있을까요.. | 연연두 | 2025-07-05 |
2700484 | 두 개가 차이가 뭔지 알려주세요...(소수 찾는 프로그램) (2) | 날위해 | 2025-07-05 |
2700426 | 인터넷 창 띄우는 질문이요 (1) | 정훈 | 2025-07-04 |
2700400 | 원넓이를 계산이요 ㅜㅜ | 천칭자리 | 2025-07-04 |
2700368 | if에 관해서 질문이요... | Orange | 2025-07-04 |
2700339 | 이거 결과값이 왜이런건지.. (4) | 그댸와나 | 2025-07-04 |
2700313 | 파일 읽어서 저장하는데 빈파일일 경우 문재가 발생하네요.. (2) | 크나 | 2025-07-03 |
2700287 | 구조체 동적할당 연습을 하는데 오류가 뜹니다...(해결) (3) | 아련나래 | 2025-07-03 |
2700264 | 문자와 숫자 동시에 입력??? | 글고운 | 2025-07-03 |
2700236 | txt파일로만 쓰고 읽게 하려면 어떻게 해야 하나요..?? (8) | 미국녀 | 2025-07-03 |
2700211 | 전위 연산자 (2) | 어른처럼 | 2025-07-02 |
2700183 | C에서 파일이름을 받고, 그 파일의 사이즈를 출력해줘야하는데 내용이 출력이 안되네요 ;ㅅ; | 피스케스 | 2025-07-02 |
2700150 | 꼭좀 도와주세요ㅠㅠㅠ | 호습다 | 2025-07-02 |
2700095 | 연산문제...질문... | 오빤테앵겨 | 2025-07-01 |
2700070 | while문 , 3의배수 출력하는 프로그램좀 짜주세욤. | 횃불 | 2025-07-01 |
2700041 | 초보인데요 ㅎ 배열안에 배열을 집어넣을수 있나요?? | 헛장사 | 2025-07-01 |
2700012 | 배열// (1) | 전갈자리 | 2025-07-01 |
2699895 | 무한루프에 빠집니다.!! 해결좀부탁드려요 (10) | 선아 | 2025-06-30 |