Java 변경 로그 생성

Java 코드의 diff 파일을 기반으로 간결한 코드 변경 로그 항목을 생성합니다.

모델을 직접 쿼리하고 Cloud 콘솔에서 다른 매개변수 값을 사용하거나 Vertex AI API를 직접 호출하여 반환된 결과를 테스트할 수 있습니다.

자유 형식 프롬프트

이 커밋의 주요 코드 변경사항을 요약하는 간결한 한 줄 변경 로그를 생성합니다.

--- /your/code/directory/tree_traversal.java
+++ //your/code/directory/tree_traversal.java

class Node {
    int data;
    Node left, right;

    public Node(int data) {
        this.data = data;
        left = right = null;
    }
}

public class TreeTraversal {

    Node root;

-    // Recursive Traversal Methods
-    public void preorderRecursive(Node node) {
-        if (node != null) {
-            System.out.print(node.data + " ");
-            preorderRecursive(node.left);
-            preorderRecursive(node.right);
-        }
-    }

+    // Iterative Traversal Methods (Using a Stack)
+    public void preorderIterative(Node node) {
+        if (node == null) {
+            return;
+        }
+        Stack stack = new Stack<>();
+        stack.push(node);
+
+        while (!stack.isEmpty()) {
+            Node current = stack.pop();
+            System.out.print(current.data + " ");
+
+            // Push right child first (changes order compared to recursive)
+            if (current.right != null) {
+                stack.push(current.right);
+            }
+            if (current.left != null) {
+                stack.push(current.left);
+            }
+        }
+    }
}

응답

스택을 사용하는 반복적 선주문 순회가 추가되었습니다.
모델: gemini-1.5-flash-001
강도: 1
최대 출력 토큰: 8192
최상위 K: 40
최상위 P: 0.95