빅오를 구하고 싶어요~
애기
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);
}
번호 | 제 목 | 글쓴이 | 날짜 |
---|---|---|---|
2655576 | 구조체 선언 질문입니다. | 통꽃 | 2024-05-21 |
2655547 | 변수선언과 printf만 사용해서 수식 짜기 (1) | 피리 | 2024-05-20 |
2655523 | 문자열 사이에 문자열삽입 | 바람 | 2024-05-20 |
2655491 | 키보드 인식, 랜덤 함수 or 헤더 (2) | 별 | 2024-05-20 |
2655471 | 링 버퍼 구현된 소스 인데요.. 이해가 잘안되서요.. | 소심한녀자 | 2024-05-20 |
2655440 | test파일이 안 되요. (2) | 리라 | 2024-05-19 |
2655416 | 고수님들 도움이 절실합니다. (2) | 세리 | 2024-05-19 |
2655361 | 엔터 입력받을때까지 기다리는 getchar (1) | 큰모음 | 2024-05-19 |
2655328 | 함수에서 포인터 (3) | 모아 | 2024-05-18 |
2655299 | 아이콘바꾸는법..? | 소 | 2024-05-18 |
2655271 | scanf 입력받으면 쭉 실행되는.. (5) | ComeOn | 2024-05-18 |
2655184 | 이 세개 프로그램좀 해결해주실.... 고수님들???? (3) | 말달리자 | 2024-05-17 |
2655129 | 다차원 배열 원소들 주소계산하는거 질문이요~ | 터전 | 2024-05-17 |
2655103 | AVRstudio MoveAxis. MoveLine 함수질문 | 앨버트 | 2024-05-16 |
2655072 | 콘솔창의 위치와 크기를 정하고 싶습니다. | 딥레드 | 2024-05-16 |
2655044 | 자료구조랑 online judge site에 대해서 질문있습니다... (1) | 뽀송뽀송 | 2024-05-16 |
2655016 | 별찍기 문제 중 이해안되는 부분이 있어요... | 도전중 | 2024-05-16 |
2654986 | 입력받은 성적을 배열에 저장하기 (3) | 안녕나야 | 2024-05-15 |
2654959 | ===========-이런거 미리 지정하는법 (1) | 김자영 | 2024-05-15 |
2654930 | 도와주십시요 ㅜㅜ 자료구조 ㅜㅜ | 도널드 | 2024-05-15 |