
브라우저 웹 서버에서 양방향으로 통신하며 HTML 문서 및 그림, 멀티미디어(ex. 동영상) 등의 컨텐츠를 열람할 수 있게 해주는 GUI 기반의 소프트웨어 프로그램 웹(Web)->World Wide Web 이런 브라우저상에서 제공되는 웹(Web)은 HTML 언어를 사용하여 작성된 문서 형태로 제공이 되며, 이러한 문서들을 웹 페이지(Web Page)라고 한다. 웹 페이지의 집합 => 웹 사이트 브라우저는 사용자가 선택한 자원(Resource)를 서버에 요청(Request)하고, 서버의 응답(Response)을 브라우저에 띄우는(Rendering) 방식으로 동작 브라우저 동작 방식 브라우저의 구조 사용자 인터페이스(User Interface) UI , 관련된 GUI 부분 브라우저 엔진(Browser Eng..
function connectedVertices(edges) { const graph = {}; for (let [from, to] of edges) { if (!graph[from]) graph[from] = []; if (!graph[to]) graph[to] = []; graph[from].push(to); graph[to].push(from); } const visited = {}; let count = 0; const dfs = (node) => { visited[node] = true; for (let neighbor of graph[node]) { if (!visited[neighbor]) { dfs(neighbor); } } }; //인자로 받은 node에서 시작하여 DFS 탐색을 수행하고..
function getDirections(matrix, from, to) { const queue = [from]; // 큐를 초기화하고 시작 정점을 삽입 const visited = new Array(matrix.lengt).fill(false); // 방문 여부를 저장할 배열 while (queue.length > 0) { const node = queue.shift(); // 큐에서 노드를 추출 if (node === to) return true; // 목적지에 도착하면 true 반환 visited[node] = true; // 방문한 노드는 visited 배열에 표시 for (let i = 0; i < matrix[node].length; i++) { if (matrix[node][i] && !v..
const levelOrderTraversal = (root) => { const result = []; // 결과를 저장할 배열 if (!root) return result; // 빈 트리일 경우 빈 배열 반환 const queue = [root]; // 큐를 초기화하고 루트 노드를 삽입 //queue라는 배열을 생성하고, 이진 트리의 루트 노드를 queue 배열에 넣는다. while (queue.length > 0) { const currentLevelSize = queue.length; // 현재 레벨의 크기 저장 const currentLevel = []; // 현재 레벨의 노드를 저장할 배열 for (let i = 0; i < currentLevelSize; i++) { const node = ..
class GraphWithAdjacencyMatrix { constructor() { this.matrix = []; } //이차원 배열(matrix)을 초기화 addVertex() { //버텍스를 추가합니다. const currentLength = this.matrix.length; for (let i = 0; i < currentLength; i++) { this.matrix[i].push(0); } this.matrix.push(new Array(currentLength + 1).fill(0)); //새로운 행(즉, 새로운 정점)을 만들고, 이를 matrix 배열의 끝에 추가 //새로운 정점은 다른 정점과 아직 연결되어 있지 않은 상태 //currentLength + 1 길이의 새로운 배열을 생성..